[indexer] Querying for OSGi metadata

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[indexer] Querying for OSGi metadata

Robert Munteanu-3
Hi,

I am building off the maven-indexer examples and trying to find
artifacts with a certain Bundle-SymbolicName. I have configured the
OSGi indexer before downloading the index

    List<IndexCreator> indexers = new ArrayList<>();
    indexers.add(plexusContainer.lookup(IndexCreator.class, "min"));
    indexers.add(plexusContainer.lookup(IndexCreator.class,
"jarContent"));
    indexers.add(plexusContainer.lookup(IndexCreator.class, "maven-
plugin"));
    indexers.add(plexusContainer.lookup(IndexCreator.class, "osgi-
metadatas"));

and am firing off a query for the BSN field

    BooleanQuery q = new BooleanQuery();
    q.add(indexer.constructQuery(OSGI.SYMBOLIC_NAME, new
SourcedSearchExpression(bsn)), Occur.MUST);

When running the search I get a logged warning

[WARNING] EXACT type of querying for non-keyword (but stored) field
urn:osgi#exportPackage (with 1 registered index fields) was tried.
Please review your code, or indexCreator involved, since this type of
querying of this field is currently unsupported.

and then a NPE ( see end of mail ).

What am I doing wrong? My understanding is that these fields should be
available for querying. Is there another way of querying for this data?

Thanks,

Robert

(Please keep me in CC, I am not subscribed to this mailing list)

Exception in thread "main" java.lang.NullPointerException
        at
org.apache.lucene.search.BooleanQuery.rewrite(BooleanQuery.java:363)
        at
org.apache.lucene.search.IndexSearcher.rewrite(IndexSearcher.java:592)
        at
org.apache.lucene.search.Searcher.createNormalizedWeight(Searcher.java:
167)
        at
org.apache.lucene.search.IndexSearcher.createNormalizedWeight(IndexSear
cher.java:664)
        at
org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:383)
        at
org.apache.maven.index.DefaultSearchEngine.doSearchWithCeiling(DefaultS
earchEngine.java:336)
        at
org.apache.maven.index.DefaultSearchEngine.searchIteratorPaged(DefaultS
earchEngine.java:280)
        at
org.apache.maven.index.DefaultSearchEngine.forceSearchIteratorPaged(Def
aultSearchEngine.java:264)
        at
org.apache.maven.index.DefaultIndexer.searchIterator(DefaultIndexer.jav
a:157)
        at
nu.muntea.ca.maven.impl.OsgiArtifactLocator.searchForSlingBundles(OsgiA
rtifactLocator.java:137)
        at
nu.muntea.ca.maven.impl.OsgiArtifactLocator.run(OsgiArtifactLocator.jav
a:118)
        at
nu.muntea.ca.maven.impl.OsgiArtifactLocator.main(OsgiArtifactLocator.ja
va:47)

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [indexer] Querying for OSGi metadata

Robert Munteanu-3
On Wed, 2017-06-21 at 12:04 +0300, Robert Munteanu wrote:

> Hi,
>
> I am building off the maven-indexer examples and trying to find
> artifacts with a certain Bundle-SymbolicName. I have configured the
> OSGi indexer before downloading the index
>
>     List<IndexCreator> indexers = new ArrayList<>();
>     indexers.add(plexusContainer.lookup(IndexCreator.class, "min"));
>     indexers.add(plexusContainer.lookup(IndexCreator.class,
> "jarContent"));
>     indexers.add(plexusContainer.lookup(IndexCreator.class, "maven-
> plugin"));
>     indexers.add(plexusContainer.lookup(IndexCreator.class, "osgi-
> metadatas"));
>
> and am firing off a query for the BSN field
>
>     BooleanQuery q = new BooleanQuery();
>     q.add(indexer.constructQuery(OSGI.SYMBOLIC_NAME, new
> SourcedSearchExpression(bsn)), Occur.MUST);
>
>

Just to answer my own question, I am now using a StringSearchExpression
instead of a SourcedSearchExpression. The downside is that the matches
are not exact, so I need to filter again when the results come in.

Not ideal, but workable.

If there's a better solution I would be happy to see it.

Thanks,

Robert

> When running the search I get a logged warning
>
> [WARNING] EXACT type of querying for non-keyword (but stored) field
> urn:osgi#exportPackage (with 1 registered index fields) was tried.
> Please review your code, or indexCreator involved, since this type of
> querying of this field is currently unsupported.
>
> and then a NPE ( see end of mail ).
>
> What am I doing wrong? My understanding is that these fields should
> be
> available for querying. Is there another way of querying for this
> data?
>
> Thanks,
>
> Robert
>
> (Please keep me in CC, I am not subscribed to this mailing list)
>
> Exception in thread "main" java.lang.NullPointerException
> at
> org.apache.lucene.search.BooleanQuery.rewrite(BooleanQuery.java:363)
> at
> org.apache.lucene.search.IndexSearcher.rewrite(IndexSearcher.java:592
> )
> at
> org.apache.lucene.search.Searcher.createNormalizedWeight(Searcher.jav
> a:
> 167)
> at
> org.apache.lucene.search.IndexSearcher.createNormalizedWeight(IndexSe
> ar
> cher.java:664)
> at
> org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:383)
> at
> org.apache.maven.index.DefaultSearchEngine.doSearchWithCeiling(Defaul
> tS
> earchEngine.java:336)
> at
> org.apache.maven.index.DefaultSearchEngine.searchIteratorPaged(Defaul
> tS
> earchEngine.java:280)
> at
> org.apache.maven.index.DefaultSearchEngine.forceSearchIteratorPaged(D
> ef
> aultSearchEngine.java:264)
> at
> org.apache.maven.index.DefaultIndexer.searchIterator(DefaultIndexer.j
> av
> a:157)
> at
> nu.muntea.ca.maven.impl.OsgiArtifactLocator.searchForSlingBundles(Osg
> iA
> rtifactLocator.java:137)
> at
> nu.muntea.ca.maven.impl.OsgiArtifactLocator.run(OsgiArtifactLocator.j
> av
> a:118)
> at
> nu.muntea.ca.maven.impl.OsgiArtifactLocator.main(OsgiArtifactLocator.
> ja
> va:47)


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Loading...