Reputation: 15
How to query the indexed content in Lucene. Do we need to write any script or any api's available to query the index.
Upvotes: 0
Views: 914
Reputation: 10142
How to query the indexed content in Lucene? You write a Java class using ÌndexReader
and ÌndexSearcher
classes of Lucene API. You need to build a query and pass on to searcher instance as parameter. There is no automatic REST point.
Lucene is simply an API, originally in Java then later ported to.NET too so either you can use Java or C# to develop your index creator as well as index searcher programs.
Your searcher code will eventually be a Java Class and it is you - the programmer who might wish to expose search logic via a REST End Point. Lucene doesn't provide any off the shelf things like that.
IndexReader and IndexSearcher are main Java classes for searching an index.
Lucene API changes heavily from one version to another so look for code examples for only your chosen version.
As per accepted answer of this SO Question, its possible to search a lucene index with SOLR. I have personally not performed that kind of search though.
Upvotes: 1
Reputation: 15789
No, Lucene is a library; you have to write custom java code to do anything useful with it.
If you are looking for something higher level, that does not require you to write code, look for Solr or elasticsearch both of which are built on top of Lucene.
Upvotes: 2