Question about autocomplete feature

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Question about autocomplete feature

Aleksey Gogolev

Hello.

I'm trying to implement autocomplete feature using the snippet posted
by Dan.
(http://mail-archives.apache.org/mod_mbox/lucene-solr-user/200807.mbox/%3C1215513031.12269.12.camel@...%3E)

Here is the snippet:

<fieldType name="autocomplete" class="solr.TextField">
        <analyzer type="index">
            <tokenizer class="solr.KeywordTokenizerFactory"/>
            <filter class="solr.LowerCaseFilterFactory" />
            <filter class="solr.PatternReplaceFilterFactory"
pattern="([^a-z0-9])" replacement="" replace="all" />
            <filter class="solr.EdgeNGramFilterFactory"
maxGramSize="100" minGramSize="1" />
        </analyzer>
        <analyzer type="query">
            <tokenizer class="solr.KeywordTokenizerFactory"/>
            <filter class="solr.LowerCaseFilterFactory" />
            <filter class="solr.PatternReplaceFilterFactory"
pattern="([^a-z0-9])" replacement="" replace="all" />
            <filter class="solr.PatternReplaceFilterFactory"
pattern="^(.{20})(.*)?" replacement="$1" replace="all" />
        </analyzer>
</fieldType>
...
<field name="ac" type="autocomplete" indexed="true" stored="true"
required="false" />

First I decided to make it working for solr example. So I pasted the
snippet to schema.xml. Then I edited exampledocs/hd.xml, I added the
"ac" field to each doc. Value of "ac" field is a copy of name filed:

<add>
<doc>
  <field name="id">SP2514N</field>
  <field name="name">Samsung SpinPoint P12 SP2514N - hard drive - 250 GB - ATA-133</field>
  <field name="ac">Samsung SpinPoint P12 SP2514N - hard drive - 250 GB - ATA-133</field>
  <field name="manu">Samsung Electronics Co. Ltd.</field>
  <field name="cat">electronics</field>
  <field name="cat">hard drive</field>
  <field name="features">7200RPM, 8MB cache, IDE Ultra ATA-133</field>
  <field name="features">NoiseGuard, SilentSeek technology, Fluid Dynamic Bearing (FDB) motor</field>
  <field name="price">92</field>
  <field name="popularity">6</field>
  <field name="inStock">true</field>
</doc>

<doc>
  <field name="id">6H500F0</field>
  <field name="name">Maxtor DiamondMax 11 - hard drive - 500 GB - SATA-300</field>
  <field name="ac">Maxtor DiamondMax 11 - hard drive - 500 GB - SATA-300</field>
  <field name="manu">Maxtor Corp.</field>
  <field name="cat">electronics</field>
  <field name="cat">hard drive</field>
  <field name="features">SATA 3.0Gb/s, NCQ</field>
  <field name="features">8.5ms seek</field>
  <field name="features">16MB cache</field>
  <field name="price">350</field>
  <field name="popularity">6</field>
  <field name="inStock">true</field>
</doc>
</add>

Then I clean solr index, posted hd.xml and restarted solr server. But
when I'm trying to search for "samsu" (the part of word "samsung") I
still get no result. Seems like solr treats "ac" field like the
regular field.

What did I do wrong?

Thanks in advance.

--
Aleksey Gogolev
developer,
dev.co.ua
Aleksey

Reply | Threaded
Open this post in threaded view
|

Re: Question about autocomplete feature

hossman
: First I decided to make it working for solr example. So I pasted the
: snippet to schema.xml. Then I edited exampledocs/hd.xml, I added the
: "ac" field to each doc. Value of "ac" field is a copy of name filed:

you didn't need to do that, you could have just used a copyField to make
"ac" get a copy of "name" for all docs.

: Then I clean solr index, posted hd.xml and restarted solr server. But
: when I'm trying to search for "samsu" (the part of word "samsung") I
: still get no result. Seems like solr treats "ac" field like the
: regular field.

what exactly did you query for?  if your URL looked like this...

   http://localhost:8983/solr/select?q=samsu

...then you are just searching the default field (and it doesn't sound
like you changed that to "ac") ... you either need to change the defualt
field in your schema, or be explicit in the URL...

   http://localhost:8983/solr/select?q=ac:samsu

...in general adding the debugQuery=true option to your URLs can help you
diagnose problems like this.  Among other things it will show you a string
representing what query Solr is building after it parses your input (and
would most like have said "text:samsu")


-Hoss

Reply | Threaded
Open this post in threaded view
|

RE: Question about autocomplete feature

sundar shankar
In reply to this post by Aleksey Gogolev
Did u reindex after the change?



> Date: Wed, 27 Aug 2008 23:43:05 +0300
> From: [hidden email]
> To: [hidden email]
> Subject: Question about autocomplete feature
>
>
> Hello.
>
> I'm trying to implement autocomplete feature using the snippet posted
> by Dan.
> (http://mail-archives.apache.org/mod_mbox/lucene-solr-user/200807.mbox/%3C1215513031.12269.12.camel@...%3E)
>
> Here is the snippet:
>
> <fieldType name="autocomplete" class="solr.TextField">
>         <analyzer type="index">
>             <tokenizer class="solr.KeywordTokenizerFactory"/>
>             <filter class="solr.LowerCaseFilterFactory" />
>             <filter class="solr.PatternReplaceFilterFactory"
> pattern="([^a-z0-9])" replacement="" replace="all" />
>             <filter class="solr.EdgeNGramFilterFactory"
> maxGramSize="100" minGramSize="1" />
>         </analyzer>
>         <analyzer type="query">
>             <tokenizer class="solr.KeywordTokenizerFactory"/>
>             <filter class="solr.LowerCaseFilterFactory" />
>             <filter class="solr.PatternReplaceFilterFactory"
> pattern="([^a-z0-9])" replacement="" replace="all" />
>             <filter class="solr.PatternReplaceFilterFactory"
> pattern="^(.{20})(.*)?" replacement="$1" replace="all" />
>         </analyzer>
> </fieldType>
> ...
> <field name="ac" type="autocomplete" indexed="true" stored="true"
> required="false" />
>
> First I decided to make it working for solr example. So I pasted the
> snippet to schema.xml. Then I edited exampledocs/hd.xml, I added the
> "ac" field to each doc. Value of "ac" field is a copy of name filed:
>
> <add>
> <doc>
>   <field name="id">SP2514N</field>
>   <field name="name">Samsung SpinPoint P12 SP2514N - hard drive - 250 GB - ATA-133</field>
>   <field name="ac">Samsung SpinPoint P12 SP2514N - hard drive - 250 GB - ATA-133</field>
>   <field name="manu">Samsung Electronics Co. Ltd.</field>
>   <field name="cat">electronics</field>
>   <field name="cat">hard drive</field>
>   <field name="features">7200RPM, 8MB cache, IDE Ultra ATA-133</field>
>   <field name="features">NoiseGuard, SilentSeek technology, Fluid Dynamic Bearing (FDB) motor</field>
>   <field name="price">92</field>
>   <field name="popularity">6</field>
>   <field name="inStock">true</field>
> </doc>
>
> <doc>
>   <field name="id">6H500F0</field>
>   <field name="name">Maxtor DiamondMax 11 - hard drive - 500 GB - SATA-300</field>
>   <field name="ac">Maxtor DiamondMax 11 - hard drive - 500 GB - SATA-300</field>
>   <field name="manu">Maxtor Corp.</field>
>   <field name="cat">electronics</field>
>   <field name="cat">hard drive</field>
>   <field name="features">SATA 3.0Gb/s, NCQ</field>
>   <field name="features">8.5ms seek</field>
>   <field name="features">16MB cache</field>
>   <field name="price">350</field>
>   <field name="popularity">6</field>
>   <field name="inStock">true</field>
> </doc>
> </add>
>
> Then I clean solr index, posted hd.xml and restarted solr server. But
> when I'm trying to search for "samsu" (the part of word "samsung") I
> still get no result. Seems like solr treats "ac" field like the
> regular field.
>
> What did I do wrong?
>
> Thanks in advance.
>
> --
> Aleksey Gogolev
> developer,
> dev.co.ua
> Aleksey
>

_________________________________________________________________
Movies, sports & news! Get your daily entertainment fix, only on live.com
http://www.live.com/?scope=video&form=MICOAL