lucene-solr-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dave <>
Subject Using SOLR Autocomplete for addresses (i.e. multiple terms)
Date Mon, 02 Jan 2012 23:44:01 GMT

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

<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">
        <tokenizer class="solr.KeywordTokenizerFactory"/>
        <filter class="solr.LowerCaseFilterFactory"/>

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:


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:


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"
    <lst name="defaults">
        <str name="spellcheck">true</str>
        <str name="spellcheck.dictionary">suggest</str>
        <str name="spellcheck.count">10</str>
    <arr name="components">

<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/>

Thanks for any assistance!

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message