Search code examples
solrlucenesolrjsolrcloud

Search with special character "-" not working in Apache Solr


I have Customer data indexed in Apache Solr with details such as name, address, contact numbers, birth date, etc.

I am trying to search the index with the following query, but couldn't get any results.

http://locahost:8983/solr/customer/select?q=address:ATA-1234

here the special character "-" is used to search the contact number field.

http://locahost:8983/solr/customer/select?q=address:ATA\-1234
http://locahost:8983/solr/customer/select?q=address:"ATA\-1234"
http://locahost:8983/solr/customer/select?q=address:"ATA-1234"
http://locahost:8983/solr/customer/select?q=contact:*01\-1234*

Can someone please clarify the above queries?


Solution

  • The below query works well with forward-slash (/).

    http://localhost:8983/solr/tech_products/select?q=name:ata/-133
    

    Example : Input Value : "Samsung SpinPoint P120 SP2514N - hard drive - 250 GB - ATA-133"

    With StandardTokenizer, the value is split into tokens as below

    ST Samsung  SpinPoint P120  SP2514N hard drive  250 GB  ATA 133
    

    With ClassicTokenizer, the value is split into tokens as below.

    ST Samsung  SpinPoint P120  SP2514N hard drive  250 GB  ATA-133