Reputation: 1174
I'm using solr for the search functionality on my webapp. I append an "*" to the end of each user's search. So, if the search is: foo
I change it to filename:foo*
This works fine, except that often a hyphen will be included in the user's search. A search of filename:foo-bar*
returns zero results, as the hyphen removes any search results produced from the search term(s) after it. I can escape it, as filename:foo\-bar*
but I still get zero results. If I try filename:foo"-"*
the search returns all documents.
Any suggestions on how to get -
and *
to play nice with one another?
Thanks for the help
Upvotes: 3
Views: 1557
Reputation: 538
In my experience, I've had to escape the wildcard character if anything else in the string is escaped. This is to get it to function as a wildcard; you'd think it'd make it look for the character itself, but it seems not to. Note: Escaping the * without other escaped characters seems to search exactly for the character *, and does not use it as a wildcard operator.
field:*and\/or* //would NOT perform a wildcarded search for "and/or"
field:\*and\/or\* //would perform wildcard search for and/or
To be clear, it seems like they are backwards, but that is what hass worked in my cases.
Upvotes: 1