I am using compass based indexing on my project. My annotation based configuration for the field ‘name’ is :
@SearchableProperty(name="name")
@SearchableMetaData(name="ordering_name", index=Index.NOT_ANALYZED)
private String name;
Now following values are store for ‘name’ field :
1. Temp 0 New n/a
2. e/f search
3. c/d search
Now the search result with difference scenarios is as follows :
1. 'c/d' -> +(+alias:TempClass +(c/d*)) +(alias:TempClass) -> 1 record found
2. 'n/a' -> +(+alias:TempClass +(n/a*)) +(alias:TempClass) -> 0 record found
3. 'search' -> +(+alias:TempClass +(search*)) +(alias:TempClass) -> 2 records found
So when I am trying to search ‘n/a’, it should search the first record with value ‘Temp 0 New n/a’.
Any help would be highly appreciated !!!
At some point your query analysis doesn’t match with your Document analysis.
Most likely you are internally using Lucene’s StandardAnalyzer on the query parsing but not at index time, as detonated by:
The StandardTokenizer used inside this analyzer considers the character
/as a word boundary (such as space would be), producing the tokensnanda. Later on, the tokenais removed by a StopFilter.The following code is an example for this explanation (the input is
"c/d e/f n/a"):You’ll see the following extracted tokens:
Notice that the expected position 6: with token
ais missing. As you can see, Lucene’s QueryParser also performs this tokenization:The output is:
EDIT: The solution would be to use WhitespaceAnalyzer, and set the field to ANALYZED. The following code is a proof of concept under Lucene:
The output is:
1.