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 Vincent Pérès <vi...@gmail.com> on 2009/09/16 11:25:29 UTC

Need help to finalize my autocomplete

Hello,

I'm using the following code for my autocomplete feature :

The field type :

    <fieldType name="autoComplete" class="solr.TextField" omitNorms="true">
      <analyzer>
        <tokenizer class="solr.WhitespaceTokenizerFactory" />
        <filter class="solr.LowerCaseFilterFactory" />
        <filter class="solr.EdgeNGramFilterFactory" maxGramSize="20"
minGramSize="2" />
      </analyzer>
      <analyzer type="query">
        <tokenizer class="solr.WhitespaceTokenizerFactory" />
        <filter class="solr.LowerCaseFilterFactory" />
        <filter class="solr.PatternReplaceFilterFactory"
pattern="^(.{20})(.*)?" replacement="$1" replace="all" />
      </analyzer>
    </fieldType>

The field :

<dynamicField name="*_ac" type="autoComplete" indexed="true" stored="true"
/>

The query :
?q=*:*&fq=query_ac:harry*&wt=json&rows=15&start=0&fl=*&indent=on&fq=model:SearchQuery

It gives me a list of results I can parse and use with jQuery autocomplete
plugin and all that works very well.

Example of results :
> harry
> harry potter
> the last fighting harry
> harry potter 5
> comic relief harry potter

What I would like to do now is only to have results starting with the query,
so it should be :
> harry
> harry potter
> harry potter 5

Can anybody tell me if it is possible and so how to do it ?

Thank you !
Vincent
And 
-- 
View this message in context: http://www.nabble.com/Need-help-to-finalize-my-autocomplete-tp25468885p25468885.html
Sent from the Solr - User mailing list archive at Nabble.com.


Re: Need help to finalize my autocomplete

Posted by Vincent Pérès <vi...@gmail.com>.
After re-indexing it works very well ! Thanks a lot !

Vincent
-- 
View this message in context: http://www.nabble.com/Need-help-to-finalize-my-autocomplete-tp25468885p25469931.html
Sent from the Solr - User mailing list archive at Nabble.com.


Re: Need help to finalize my autocomplete

Posted by Shalin Shekhar Mangar <sh...@gmail.com>.
2009/9/16 Vincent Pérès <vi...@gmail.com>

>
> Hello,
>
> I tried to replace the class as you suggested, but I still get the same
> result (and not results where the query start only with the giving query).
>
>
Make sure you re-index your documents after change the schema.

-- 
Regards,
Shalin Shekhar Mangar.

Re: Need help to finalize my autocomplete

Posted by Vincent Pérès <vi...@gmail.com>.
Hello,

I tried to replace the class as you suggested, but I still get the same
result (and not results where the query start only with the giving query).

<fieldType name="autoComplete" class="solr.TextField" omitNorms="true">
      <analyzer>
        <tokenizer class="solr.KeywordTokenizerFactory" />
        <filter class="solr.LowerCaseFilterFactory" />
        <filter class="solr.EdgeNGramFilterFactory" maxGramSize="20"
minGramSize="2" />
      </analyzer>
      <analyzer type="query">
        <tokenizer class="solr.KeywordTokenizerFactory" />
        <filter class="solr.LowerCaseFilterFactory" />
        <filter class="solr.PatternReplaceFilterFactory"
pattern="^(.{20})(.*)?" replacement="$1" replace="all" />
      </analyzer>
    </fieldType>
-- 
View this message in context: http://www.nabble.com/Need-help-to-finalize-my-autocomplete-tp25468885p25469239.html
Sent from the Solr - User mailing list archive at Nabble.com.


Re: Need help to finalize my autocomplete

Posted by Avlesh Singh <av...@gmail.com>.
Instead of <tokenizer class="solr.WhitespaceTokenizerFactory" /> use
<tokenizer class="solr.KeywordTokenizerFactory"/>

Cheers
Avlesh

2009/9/16 Vincent Pérès <vi...@gmail.com>

>
> Hello,
>
> I'm using the following code for my autocomplete feature :
>
> The field type :
>
>    <fieldType name="autoComplete" class="solr.TextField" omitNorms="true">
>      <analyzer>
>        <tokenizer class="solr.WhitespaceTokenizerFactory" />
>        <filter class="solr.LowerCaseFilterFactory" />
>        <filter class="solr.EdgeNGramFilterFactory" maxGramSize="20"
> minGramSize="2" />
>      </analyzer>
>      <analyzer type="query">
>        <tokenizer class="solr.WhitespaceTokenizerFactory" />
>        <filter class="solr.LowerCaseFilterFactory" />
>        <filter class="solr.PatternReplaceFilterFactory"
> pattern="^(.{20})(.*)?" replacement="$1" replace="all" />
>      </analyzer>
>    </fieldType>
>
> The field :
>
> <dynamicField name="*_ac" type="autoComplete" indexed="true" stored="true"
> />
>
> The query :
>
> ?q=*:*&fq=query_ac:harry*&wt=json&rows=15&start=0&fl=*&indent=on&fq=model:SearchQuery
>
> It gives me a list of results I can parse and use with jQuery autocomplete
> plugin and all that works very well.
>
> Example of results :
> > harry
> > harry potter
> > the last fighting harry
> > harry potter 5
> > comic relief harry potter
>
> What I would like to do now is only to have results starting with the
> query,
> so it should be :
> > harry
> > harry potter
> > harry potter 5
>
> Can anybody tell me if it is possible and so how to do it ?
>
> Thank you !
> Vincent
> And
> --
> View this message in context:
> http://www.nabble.com/Need-help-to-finalize-my-autocomplete-tp25468885p25468885.html
> Sent from the Solr - User mailing list archive at Nabble.com.
>
>