Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to do partial beginning matches in Solr?

Tags:

solr

I'm trying to search for partial beginning matches on a big list of lastnames. So Wein* should find Weinberg, Weinkamm etc.

I could do this by creating a special field, and adding

<filter class="solr.EdgeNGramFilterFactory" minGramSize="1" maxGramSize="50" preserveOriginal="1"/>

to its type specification in schema.xml. When I add the line above only to the indexing analyzer and leave it empty for the query analyzer, I can then search by just search special_field:Wein and get the expected results.

Now I see that solr also has a *-syntax. What's the connection between EdgeNGramFilterFactory and the *-syntax?

Am I doing things correctly or is there a better, more regular way?

Thanks!

like image 256
CruftyCraft Avatar asked May 06 '10 12:05

CruftyCraft


1 Answers

Or just do a simple wild card match:

name:Pe*
like image 178
Petah Avatar answered Oct 20 '22 01:10

Petah