How to query wildcard with whitespace in Solr

Recently my team is working on a project where it uses Apache Solr. It's very useful when an application's main feature is search since it's providing full-text search with many other interesting search features.

But while working on it, we faced an issue that, we can't query wildcard with whitespace included.

Problem:

we want to search apache solr in technology field. So the query should be like,

q=technology:*apache solr

But the problem is, it was not showing any results. The main reason behind is that whitespace between apache and solr.

Solution:

Actually the solution is very simple, we just replaced the whitespace with \

So the new modified query was looking like,

q=technology:*apache\ solr

This simple fix solves saves our day. But note that, this will work for string fields not text fields.

comments powered by Disqus