lucene-solr-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jan Høydahl <>
Subject Re: Using SOLR Autocomplete for addresses (i.e. multiple terms)
Date Tue, 03 Jan 2012 13:24:57 GMT

As you see, you've got an answer at StackOverflow already with a proposed solution to implement
your own QueryConverter.

Another way is to create a Solr core solely for Suggest, and tune it exactly the way you like.
Then you can have it suggest from the whole input as well as individual tokens and weigh these
as you choose, as well as implement phonetic normalization and other useful tricks.

Jan Høydahl, search solution architect
Cominvent AS -
Solr Training -

On 3. jan. 2012, at 00:52, Dave wrote:

> Hi,
> I'm reposting my StackOverflow question to this thread as I'm not getting
> much of a response there. Thank you for any assistance you can provide!
> I'm new to SOLR, but I've got it up and running, indexing data via the DIH,
> and properly returning results for queries. I'm trying to setup another
> core to run suggester, in order to autocomplete geographical locations. We
> have a web application that needs to take a city, state / region, country
> input. We'd like to do this in a single entry box. Here are some examples:
> Brooklyn, New York, United States of America
> Philadelphia, Pennsylvania, United States of America
> Barcelona, Catalunya, Spain
> Assume for now that every location around the world can be split into this
> 3-form input. I've setup my DIH to create a TemplateTransformer field that
> combines the 4 tables (city, state and country are all independent tables
> connected to each other by a master places table) into a field called
> "fullplacename":
> <field column="fullplacename" template="${city_join.plainname},
> ${region_join.plainname}, ${country_join.plainname}"/>
> I've defined a "text_auto" field in schema.xml:
> <fieldType class="solr.TextField" name="text_auto">
>    <analyzer>
>        <tokenizer class="solr.KeywordTokenizerFactory"/>
>        <filter class="solr.LowerCaseFilterFactory"/>
>    </analyzer>
> </fieldType>
> and have defined these two fields as well:
> <field name="name_autocomplete" type="text_auto" indexed="true"
> stored="true" multiValued="true" />
> <copyField source="fullplacename" dest="name_autocomplete" />
> Now, here's my problem. This works fine for the first term, i.e. if I type
> "brooklyn" I get the results I'd expect, using this URL to query:
> http://localhost:8983/solr/places/suggest?q=brooklyn
> However, as soon as I put a comma and/or a space in there, it breaks them
> up into 2 suggestions, and I get a suggestion for each:
> http://localhost:8983/solr/places/suggest?q=brooklyn%2C%20ny
> Gives me a suggestion for "brooklyn" and a suggestion for "ny" instead of a
> suggestion that matches "brooklyn, ny". I've tried every solution I can
> find via google and haven't had any luck. Is there something simple that
> I've missed, or is this the wrong approach?
> Just in case, here's the searchComponent and requestHandler definition:
> <requestHandler name="/suggest"
> class="org.apache.solr.handler.component.SearchHandler">
>    <lst name="defaults">
>        <str name="spellcheck">true</str>
>        <str name="spellcheck.dictionary">suggest</str>
>        <str name="spellcheck.count">10</str>
>    </lst>
>    <arr name="components">
>        <str>suggest</str>
>    </arr>
> </requestHandler>
> <searchComponent name="suggest" class="solr.SpellCheckComponent">
>    <lst name="spellchecker">
>        <str name="name">suggest</str>
>        <str name="classname">org.apache.solr.spelling.suggest.Suggester</str>
>        <str name="lookupImpl">org.apache.solr.spelling.suggest.tst.TSTLookup</str>
>        <str name="field">name_autocomplete</str>`<br/>
>    </lst>
> </searchComponent>
> Thanks for any assistance!

View raw message