Closed (outdated)
Project:
Search API
Version:
7.x-1.x-dev
Component:
Framework
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
11 Apr 2012 at 16:31 UTC
Updated:
10 Jan 2019 at 08:13 UTC
Jump to comment: Most recent
Comments
Comment #1
tahiticlic commentedSame need here, the Lucene query syntax allows use of "*" and "?" to make the search wildcarded, and the use of "~" to make it fuzzy. But maybe (I didn't check here) this caracters are escaped...
Comment #2
damien_vancouver commentedI've been looking into this too, and I think the correct solution is to follow what was done in the ApacheSolr module at #713142: Add configuration option to a search environment if we want to use Dismax or EDismax..
The general solution involves backporting the EDisMax Query handler .java file from a newer version of Solr, recompiling a custom Solr 1.4 with this extra file, and then asking Solr to use that query handler (which supports wildcards, among other things). This is the approach taken by Acquia Search.
Several approaches were taken on that thread. By the end they had a very clean and simple solution:
- Build yourself a Solr 1.4 with the EDisMax query handler (there are instructions in REAMDE alterations to the earlier versions of the patch here: http://drupal.org/files/issues/apachesolr-713142-settings_for_handler_2.... .)
- add a defType=edismax parameter to the Solr query somehow, which will ask Solr to use this handler.
I am going to try this for Search API Solr Search. If I can get it going I'll post a patch and proper instructions for building the solr here. If I can't, I might just switch to ApacheSolr module instead... but anyway that is what needs to be done to make wildcard searches work.
If you think this sounds totally crazy that there's no way to just wildcard search out of the box... you are likely in good company :)
Comment #3
damien_vancouver commentedWell no luck on my backport. I was able to create the custom Solr OK, but couldn't figure out the correct modifications to the ->search() method in service.inc, which calls the solr search.
This is actually a duplicate issue of #1400754: Add option to use EDismax query handler. I'll post my findings from today's work there.
Comment #4
kristofferwiklund commentedBut the original issue is not for Solr search. It is for Serach API and database server.
Comment #5
damien_vancouver commentedOops sorry! My bad!
Comment #6
jonloh commentedSo there is no way for wildcard search via Search API?
Comment #7
damien_vancouver commented@jonloh,
Check out #1116896: Adapt schema.xml and solrconfig.xml for Solr 3.x. There has been a lot more work completed on making Search API compatible with Solr version 3. Over at that issue, you should be able to find working schema.xml and solrconfig.xml files which you can use to hook Search API up to the latest Solr 3.6 (or whatever the latest 3.x version is).
Once you're using Solr 3, then your default query handler will be the EDisMaxQueryHandler we're talking about above. That means you should be able to use wildcards, which Solr 1.x does not support.
You can also try the method above of backporting EDisMaxQueryHandler.java from a newer solr into your solr 1.4. I managed to pull this off but it was difficult, and I don't see the point now that Solr 3 config files are available.. so try that instead, it will be way quicker and you will get other new, nice to have Solr features as well.
Comment #8
jonloh commentedI've downloaded the latest dev and applied the patch from http://drupal.org/node/1509380#comment-6612438, which still doesn't seem to do any good in the wildcard search although I did update the solrconfig.xml and schema.xml from the 3.x folder.
However, I do read somewhere that by default the EDisMaxQueryHandler is disabled and we will have to enable it, or something like that? I'm running on Solr 3.6 and using Views to do the Solr search.
Comment #9
damien_vancouver commentedHmm, I thought EDisMaxQueryHandler was now the default, but maybe not.
Those config files you used are probably the ones to go with (the common ones, not the ones I referenced above).
The solrconfig.xml you're using might be defining the old "dismax" as the default. In the patch I see one spot that's happening:
You could try changing that defType to "edismax". But I'm a bit out of my depth here, it might not be that simple.
I ended up getting wildcards to work by switching to ApacheSolr module instead of Search API (as it was the only way for solr 3 at the time), then I added * to the start and end of each query using PHP code, turning every query into a wildcard query. I also had to convert my query to lower case, before I could get any search results to match (even though I was matching against a string that was all upper case). But both those were with the apacheSolr module, not Search API, so there may be differences.
A good way to verify what is actually happening on the Solr end is to look at the Solr log file / console output. In Tomcat this is in the catalina.out log file, for the standalone solr application it probably prints the the console. One of those might give you some hints as to what is going wrong, and whether the * characters are being stripped or not.
Comment #10
legolasboThis issue has not seen activity in over 2,5 years. I am therefore closing this issue to clean up the issue queue. Feel free to re-open and update this issue if you feel this issue is still relevant and of importance.