Reputation: 1039
I would like to search a book by its title. Lets say I have 2 books called
"Please do a wildcard search"
"Please do a deep search"
and then I do a solr wildcard search like the following:
{
"responseHeader":{
"status":0,
"QTime":1,
"params":{
"q":"BOOK_NAME:\"Please*search\"",
"indent":"on",
"wt":"json"}},
"response":{"numFound":0,"start":0,"docs":[]
}}
I was expecting 2 books from this search, but the number of documents founds were 0
Reference I've found the wildcard searches:
I'm using solr 6.
Upvotes: 1
Views: 138
Reputation: 1337
Your query seems to be a phrase query, ie BOOK_NAME:"Please*search"
rather than BOOK_NAME:Please*search
. That will try to find the exact phrase Please*search
Also, I don't think the query will work unless you're indexing BOOK_NAME in a way that retains the entire title as a token. Either try indexing the field as a string or maybe try using the ComplexPhraseQueryParser
The ComplexPhraseQParser provides support for wildcards, ORs, etc., inside phrase queries using Lucene's ComplexPhraseQueryParser . Under the covers, this query parser makes use of the Span group of queries, e.g., spanNear, spanOr, etc., and is subject to the same limitations as that family or parsers
{!complexphrase inOrder=true}BOOK_NAME:"Please*search"
or {!complexphrase inOrder=true}BOOK_NAME:"Please * search"
Upvotes: 1