You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by Erick Erickson <er...@gmail.com> on 2012/11/01 21:28:44 UTC

Re: Feature & design question: use autocomplete to search on 2 different fields, and return 2 different data groups

You might be able to do something like append "tags" to the suggestions.
So, you'd actually index
pizza:cat
pizza hut:business

Then you app gets these back and can display them however is most pleasing
to the user.

But.... consider that all autosuggest is doing is searching the indexed
terms. So here in michigan we have "Cottage Inn Pizza". Since it doesn't
start with "pizza", it wouldn't be returned when doing an autosuggest on
"piz". You'd have to do something like index this "pizza cottage
inn:business:Cottage Inn Pizza" in order to get back something sensible to
display....

If your speed is sufficient, you could always to a straight Solr query and
use grouping. In that case you'd have to do something like index a field
"suggest_type" and group on that field. But this may be too slow....

Best
Erick


On Thu, Nov 1, 2012 at 9:39 AM, fernando.beck <fe...@gmail.com>wrote:

> Hello,
>
>
>
>  we're facing a new feature request, and we can't get the right way to come
> up with a working solution.
>
>
>
> Context: we have a list of businesses . For each business we have: name,
> category, address, city.
>
> One business may have 1 or more categories.
>
>
>
> Example:
>
> Name: Outback SteakHouse
>
> Category: Restaurants , American
>
> Address: xxxxxx
>
> City: Rio de Janeiro
>
>
>
> Name: Starbucks
>
> Category: Bar, Coffee
>
> Address: yyyyy
>
> City: Rio de Janeiro
>
>
>
> Name:  Pizza Hut
>
> Category: Restaurant, Pizza
>
> Address: xxxx
>
> City: New York
>
>
>
> and so on.
>
>
>
> What we need to do:  create an "autocomplete" feature; whenever someone
> starts to type, we will need to search the term BOTH on CompanyName AND
> Category.
>
> Example:  I type pizz
>
>
>
> and the result should be coming back in 2 groups.
>
> Group 1: Categories  (displaying  Pizza)
>
> Group 2:  all those businesses featuring pizza on their name , ie Pizza
> Hut.
>
>
>
> Right now we can not find a way to get this done.
>
>
>
> Schema (since we're running a portuguese based application, there are 2
> fieldType added for it):
>
>
>
>
> <?xml version="1.0" encoding="UTF-8" ?>
> <schema name="Guia-DEV" version="1.5">
>   <types>
>     -->
>
>
>     <fieldType name="string" class="solr.StrField" sortMissingLast="true"
> />
>
>
>     <fieldType name="boolean" class="solr.BoolField"
> sortMissingLast="true"/>
>
>      <fieldtype name="binary" class="solr.BinaryField"/>
>
>
>
>     <fieldType name="int" class="solr.TrieIntField" precisionStep="0"
> positionIncrementGap="0"/>
>     <fieldType name="float" class="solr.TrieFloatField" precisionStep="0"
> positionIncrementGap="0"/>
>      <fieldType name="long" class="solr.TrieLongField" precisionStep="0"
> positionIncrementGap="0"/>
>     <fieldType name="double" class="solr.TrieDoubleField" precisionStep="0"
> positionIncrementGap="0"/>
>
>
>     <fieldType name="tint" class="solr.TrieIntField" precisionStep="8"
> positionIncrementGap="0"/>
>     <fieldType name="tfloat" class="solr.TrieFloatField" precisionStep="8"
> positionIncrementGap="0"/>
>      <fieldType name="tlong" class="solr.TrieLongField" precisionStep="8"
> positionIncrementGap="0"/>
>     <fieldType name="tdouble" class="solr.TrieDoubleField"
> precisionStep="8"
> positionIncrementGap="0"/>
>
>
>     <fieldType name="date" class="solr.TrieDateField" precisionStep="0"
> positionIncrementGap="0"/>
>
>
>      <fieldType name="tdate" class="solr.TrieDateField" precisionStep="6"
> positionIncrementGap="0"/>
>
>
>     <fieldType name="pint" class="solr.IntField"/>
>      <fieldType name="plong" class="solr.LongField"/>
>     <fieldType name="pfloat" class="solr.FloatField"/>
>     <fieldType name="pdouble" class="solr.DoubleField"/>
>      <fieldType name="pdate" class="solr.DateField"
> sortMissingLast="true"/>
>
>
>
>     <fieldType name="sint" class="solr.SortableIntField"
> sortMissingLast="true" omitNorms="true"/>
>      <fieldType name="slong" class="solr.SortableLongField"
> sortMissingLast="true" omitNorms="true"/>
>     <fieldType name="sfloat" class="solr.SortableFloatField"
> sortMissingLast="true" omitNorms="true"/>
>      <fieldType name="sdouble" class="solr.SortableDoubleField"
> sortMissingLast="true" omitNorms="true"/>
>
>
>     <fieldType name="random" class="solr.RandomSortField" indexed="true" />
>
>
>
>     <fieldType name="text_general" class="solr.TextField"
> positionIncrementGap="100">
>       <analyzer type="index">
>         <tokenizer class="solr.StandardTokenizerFactory"/>
>          <filter class="solr.StopFilterFactory" ignoreCase="true"
> words="stopwords.txt" enablePositionIncrements="true" />
>
>         <filter class="solr.LowerCaseFilterFactory"/>
>        </analyzer>
>       <analyzer type="query">
>         <tokenizer class="solr.StandardTokenizerFactory"/>
>         <filter class="solr.StopFilterFactory" ignoreCase="true"
> words="stopwords.txt" enablePositionIncrements="true" />
>          <filter class="solr.SynonymFilterFactory" synonyms="synonyms.txt"
> ignoreCase="true" expand="true"/>
>         <filter class="solr.LowerCaseFilterFactory"/>
>        </analyzer>
>     </fieldType>
>
>
> <fieldType name="textCategoryName" class="solr.TextField"
> positionIncrementGap="100">
>        <analyzer type="index">
>         <tokenizer class="solr.WhitespaceTokenizerFactory"/>
>         <filter class="solr.WordDelimiterFilterFactory"
> generateWordParts="1" generateNumberParts="1" catenateWords="1"
> catenateNumbers="1" catenateAll="0" splitOnCaseChange="1"/>
>          <filter class="solr.ASCIIFoldingFilterFactory"/>
>         <filter class="solr.LowerCaseFilterFactory"/>
>         <filter class="solr.RemoveDuplicatesTokenFilterFactory"/>
>   <filter class="solr.SnowballPorterFilterFactory" language="Portuguese"/>
>       </analyzer>
>       <analyzer type="query">
>         <tokenizer class="solr.WhitespaceTokenizerFactory"/>
>          <filter class="solr.SynonymFilterFactory"
> synonyms="pt_categories.txt" ignoreCase="true" expand="false"/>
>         <filter class="solr.WordDelimiterFilterFactory"
> generateWordParts="1" generateNumberParts="1" catenateWords="0"
> catenateNumbers="0" catenateAll="0" splitOnCaseChange="1"/>
>          <filter class="solr.ASCIIFoldingFilterFactory"/>
>         <filter class="solr.LowerCaseFilterFactory"/>
>         <filter class="solr.RemoveDuplicatesTokenFilterFactory"/>
>   <filter class="solr.SnowballPorterFilterFactory" language="Portuguese"/>
>       </analyzer>
> </fieldType>
>
>
>
>
>
>      <fieldType name="lowercase" class="solr.TextField"
> positionIncrementGap="100">
>       <analyzer>
>         <tokenizer class="solr.KeywordTokenizerFactory"/>
>          <filter class="solr.LowerCaseFilterFactory" />
>       </analyzer>
>     </fieldType>
>
>     <fieldType name="text_path" class="solr.TextField"
> positionIncrementGap="100">
>        <analyzer>
>         <tokenizer class="solr.PathHierarchyTokenizerFactory"/>
>       </analyzer>
>     </fieldType>
>
>
>
>
>     <fieldType name="text_pt" class="solr.TextField"
> positionIncrementGap="100">
>        <analyzer type="index">
>  <charFilter class="solr.HTMLStripCharFilterFactory"/>
>         <tokenizer class="solr.StandardTokenizerFactory"/>
>          <filter class="solr.LowerCaseFilterFactory"/>
>         <filter class="solr.StopFilterFactory" ignoreCase="true"
> words="lang/stopwords_pt.txt" format="snowball"
> enablePositionIncrements="true"/>
>   <filter class="solr.ASCIIFoldingFilterFactory"/>
>       </analyzer>
>       <analyzer type="query">
>  <charFilter class="solr.HTMLStripCharFilterFactory"/>
>          <tokenizer class="solr.StandardTokenizerFactory"/>
>         <filter class="solr.LowerCaseFilterFactory"/>
>         <filter class="solr.StopFilterFactory" ignoreCase="true"
> words="lang/stopwords_pt.txt" format="snowball"
> enablePositionIncrements="true"/>
>   <filter class="solr.ASCIIFoldingFilterFactory"/>
>       </analyzer>
>     </fieldType>
> </fieldType>
>   </types>
>
>  <fields>
>    <field name="LocalBusinessId" type="int" indexed="true" stored="true"
> required="true" />
>     <field name="CompanyName" type="text_pt" indexed="true" stored="true"
> />
>    <field name="LocationName" type="text_pt" indexed="true" stored="true"
> />
>     <field name="StreetAddress" type="text_pt" indexed="true" stored="true"
> />
>    <field name="City" type="text_pt" indexed="true" stored="true" />
>     <field name="RelatedCategoriesKeywords" type="textCategoryName"
> indexed="true" stored="true" multiValued="true" />
>  </fields>
>
>
>  <uniqueKey>LocalBusinessId</uniqueKey>
>
> </schema>
>
>
>
>
> Thanks,
>
>
>
> F
>
>
>
> --
> View this message in context:
> http://lucene.472066.n3.nabble.com/Feature-design-question-use-autocomple-te-to-search-on-2-different-fields-and-return-2-different-dats-tp4017528.html
> Sent from the Solr - User mailing list archive at Nabble.com.
>