Search code examples
javaluceneindexingcompass-lucene

compass returning 0 rows with “#” (hash character) in search query


I am using compass based indexing on my project. Now in one of the scenario I have field values something like 'dummy#value'. So if I am trying to search with any of the value which contains '#' character, its returning 0 rows..

For e.g.

DummyTable

id   field_name
----------------
1    dummy#value
2    otherVal1
3    otherVal2

Query

+(+alias:DummyTable +field_name:dummy#value*) +(alias:DummyTable)

returning 0 rows, whereas

+(+alias:DummyTable +field_name:dummy*) +(alias:DummyTable)

returning 1 row..


Solution

  • I was required to annotate the field declaration as

    NOT_ANALYZED : (Index the property's value without using an Analyzer, so it can be searched)

    @SearchableProperty(index=Index.NOT_ANALYZED)
    private String field_name;