On Tue, Nov 24, 2009 at 10:12 AM, darniz <rnizamud...@edmunds.com> wrote:

>
> hello all
> Let me first explain the task i am trying to do.
> i have article with title for example
> <doc>
> <str name="title">>Car Insurance for Teenage Drivers</str>
> </doc>
> −
> <doc>
> <str name="title">A Total Loss? </str>
> </doc>
> If a user begins to type car insu i want the autopop to show up with the
> entire phrase.
> There are two ways to implement this.
> First is to use the termcomponent and the other is to use a field with
> field
> type which uses solr.EdgeNGramFilterFactor filter.
>
> I started with using with Term component and i declared a term request
> handler and gave the following query
>
> http://localhost:8080/solr/terms?terms.fl=title&terms.prefix=car
> The issue is that its not giving the entire pharse, it gives me back
> results
> like car, caravan, carbon. Now  i know using terms.prefix will only give me
> results where the sentence start with car. On top of this i also want if
> there is word like car somewhere in between the title that should also show
> up in autopop very much similar like google where a word is not necessarily
> start at the beginning but it could be present anywhere in the middle of
> the
> title.
> The question is does TermComponent is a good candidate or  using a custom
> field lets the name is autoPopupText with field type configured with all
> filter and EdgeNGramFilterFactor defined and copying the title to the
> autoPopupText field and using it to power autopopup.
>
> The other thing is that using  EdgeNGramFilterFactor is more from index
> point of view when you index document you need to know which fields you
> want
> to copy to autoPopupText field where as using Term component is more like
> you can define at query time what fields you want to use to fetch
> autocomplete from.
>
> Any idea whats the best and why the Term component is not giving me an
> entire phrase which i mentioned earlier.
> FYI
> my title field is of type text.
>


You are using a tokenized field type with TermsComponent therefore each word
in your phrase gets indexed as a separate token. You should use a
non-tokenized type (such as a string type) with TermsComponent. However,
this will only let you search by prefix and not by words in between the
phrase.

Your best bet here would be to use EdgeNGramFilterFactory. If your index is
very large, you can consider doing a prefix search on shingles too.

-- 
Regards,
Shalin Shekhar Mangar.

Reply via email to