[TYPO3-Solr] Advanced search with SOLR

Ingo Renner ingo at typo3.org
Tue Jul 31 11:45:10 CEST 2012


Am 26.07.12 14:13, schrieb Christian Bleicher - DieLobby Werbeagentur Gmbh:

Hi Christian,

> I try to implement an advanced search using SOLR. I want to search for
> Website users and they are already indexed. If i search using the q
> paramenter it works great.
> But now I have to implement a advanced search using special field like
> firstname, lastname and city. If I search for Regensburg in the city
> field, I won't find someone who is called Regensburg (lastname).
> Now I tryed to use the filter options from SOLR.
>
> It works with an 100% match if I try it with this link (simply like the
> tx_solr filters)
> http://.../search.html?tx_solr[q]=*&tx_solr[filter][1]=city%3ARegensburg
>
> But if I search for 'Regensb' it doesn't find anything. * and % didn't
> help here.
> http://petnology.rigardi.com/en/network/search.html?tx_solr[q]=*&tx_solr[filter][1]=city%3ARegensb
>
> Is there a way to implement a fuzzy search? It would be ok if it works
> like a mysql query like '%Regensb%'.

There are several things here: First and foremost I would like to advise 
simply dropping the idea of building an "advanced" form. Nobody wants to 
use them anyway...

If you absolutely have/want to go this route, here're some pointers.

* To search specific fields simply query for fieldName:fieldValue. You 
might want to prefix the field internally so the user doesn't need to 
know the field names. You probably do not want/need to use filters.
* Do not (unless you really know what you're doing) modify the 
schema.xml. Use dynamic fields instead. [1]
* For "advanced" forms you should use the standard query request 
handler, by default we use the Dismax request handler.
* Wildcards are supported by using the asterisk character (*), but not 
for leading wildcards.
* The 100% only matches is an issue of your choice of field types. My 
guess is you're using a string field here, whereas you probably want a 
text type field.
* You will have to implement most of the things through different hooks. 
Each hook in EXT:solr has an interface. So by looking into 
EXT:solr/interfaces/ you should get an idea of what can be extended. By 
looking up where an interface is used in the code you'll also see how to 
use it.


HTH,
Ingo

[1] http://forge.typo3.org/projects/extension-solr/wiki/Dynamic_Fields

-- 
Ingo Renner
TYPO3 Core Developer, Release Manager TYPO3 4.2, Admin Google Summer of Code

TYPO3 - Open Source Enterprise Content Management System
http://typo3.org

Apache Solr for TYPO3 -
Open Source Enterprise Search meets Open Source Enterprise CMS
http://www.typo3-solr.com


More information about the TYPO3-project-solr mailing list