0
votes

I am trying to search using Apache Lucene index. For it i have created Lucene index on a field filepath which is showing the path and it is not analyzed .

Now i am not able to search on the non analyzed field . Is it possible to search on non analyzed field . or is there any way to stop the splitting of the words to be store while analyzed.

3

3 Answers

2
votes

You're able to search for non-analyzed field query but there will be a match only in case of field value being completely equals to search term. As mindas mentioned - phrase query should be used for that.

In case you want to search for that field, you'd need to reindex your documents with that field being analyzed.

You can try using existing Analyzers / Tokenizers (i.e. set StandardAnalyzer when creating IndexWriter, for example) or implement your own one that will split file path into tokens using file separator as delimiter.

In case you're interested, there's Solr's PathHierarchyTokenizerFactory that already splits some hierarchical path into tokens before storing then to index and that makes file path search much easier.

1
votes

Is it possible to search on non analyzed field

In order to search non-analyzed fields, you need to use phrase query.

or is there any way to stop the splitting of the words to be store while analyzed

Sorry, I don't get this. If a field is not analyzed, it is neither split and stored as is. Can you clarify your question?

0
votes

Yes, you can replace standardAnalyzer by others like KeywordAnalyzer in IndexSearcher config. It will treat the field as one term for search.