solr query with white space

How is your itemtype field analysed?

If it is of type string , then use:

fq=itemtype:"Supply Chain Intermediaries"

Otherwise you can also try:

fq=itemtype:(Supply Chain Intermediaries)

Assuming OR is the default operator in your config and text is the default search field, your query will get translated to:

fq=itemtype:Supply OR text:(Chain Intermediaries)

Chain and Intermediaries are searched against default search field.


I have tried different solutions mentioned here, but none of them worked. However I solved it like this:

fq=itemtype: *Supply\ Chain\ Intermediaries*

Here space will be escaped with \

The above string will match with the strings Lorem Supply Chain Intermediaries Ipsum

If you are having a word starts with Supply Chain Intermediaries Ipsum then just give

fq=itemtype: Supply\ Chain\ Intermediaries*

This doesn't answer this question directly but it may help with this problem:

Remove the spaces before posting to Solr.

For fields used for faceting rather than searching, it is not important to store the value with spaces. The value is simply a treated as key. Store the field itemtype like so:"supplychainintermediaries", "monitorauditorfirm", etc.

When you display the facet values to the user, simply use a dictionary which maps key values to display values. Like so:

"supplychainintermediaries" --> "Supply Chain Intermediaries" "monitorauditorfirm" --> "Monitor/Auditor Firm"

Tags:

Solr