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 Mysurf Mail <st...@gmail.com> on 2013/08/08 13:52:28 UTC

Solr - how do I index barcode

I have a documnet that contains the following data

car {
    id:     guid
    name:   string
    sku:   list<barcode>
}

Now, The barcodes dont have a pattern. It can be either one of the
follwings:

ABCD-EF34GD-JOHN
ABCD-C08-YUVF

I want to index my documents so that search for
1. ABCD will return both.
2. AB will return both.
3. JO - will return ABCD-EF34GD-JOHN but not car with name john.

so far I have defined car and sku as text_en.
But I dont get bulletes no 2 and 3.
IS there a better way to define sku attribute.
Thanks.

Re: Solr - how do I index barcode

Posted by Andre Bois-Crettez <an...@kelkoo.com>.
I would go with a tokenizer to split each character as a separate token.
(maybe
https://cwiki.apache.org/confluence/display/solr/Tokenizers#Tokenizers-RegularExpressionPatternTokenizer
can do)
Add a LowerCaseFilterFactory so that casing is ignored.
Untested :
<fieldTypename="sku_custom"class="solr.TextField"positionIncrementGap="100">
<analyzer>
<tokenizerclass="solr.PatternTokenizerFactory"pattern="'(.)"group="0"/>
<tokenizerclass="solr.LowerCaseFilterFactory"/>
</analyzer>
</fieldType>


sku : "ABCD-EF34GD-JOHN"
would become :
sku : "a" "b" "c" "d" "-" "e" "f" "3" "4" "g" "d" "-" "j" "o" "h" "n"

Then same for query, and issue phrase searches on the sku field.
q=sku:"John"
would become :
sku : "j" "o" "h" "n"

This should work, otherwise verify what happens on the "analysis" page
of the solr admin webapp.


However, can you explain :
"3. JO - will return ABCD-EF34GD-JOHN but not car with name john."
How do you search for car named john then ?
Either queries ask explicitely for name or sku field, or matches will be
cross-fields.

André

On 08/08/2013 02:27 PM, Mysurf Mail wrote:
> 2. notes
> 1. My current query is similiar to this
> http://127.0.0.1:8983/solr/vault/select?q=ABCD&qf=Name+SKU&defType=edismax
>
> 2. I want it to be case insensitive
>
>
>
>
> On Thu, Aug 8, 2013 at 2:52 PM, Mysurf Mail<st...@gmail.com>  wrote:
>
>> I have a documnet that contains the following data
>>
>> car {
>>      id:     guid
>>      name:   string
>>      sku:   list<barcode>
>> }
>>
>> Now, The barcodes dont have a pattern. It can be either one of the
>> follwings:
>>
>> ABCD-EF34GD-JOHN
>> ABCD-C08-YUVF
>>
>> I want to index my documents so that search for
>> 1. ABCD will return both.
>> 2. AB will return both.
>> 3. JO - will return ABCD-EF34GD-JOHN but not car with name john.
>>
>> so far I have defined car and sku as text_en.
>> But I dont get bulletes no 2 and 3.
>> IS there a better way to define sku attribute.
>> Thanks.
>>
>
> --
> André Bois-Crettez
>
> Software Architect
> Search Developer
> http://www.kelkoo.com/

Kelkoo SAS
Société par Actions Simplifiée
Au capital de € 4.168.964,30
Siège social : 8, rue du Sentier 75002 Paris
425 093 069 RCS Paris

Ce message et les pièces jointes sont confidentiels et établis à l'attention exclusive de leurs destinataires. Si vous n'êtes pas le destinataire de ce message, merci de le détruire et d'en avertir l'expéditeur.

Re: Solr - how do I index barcode

Posted by Mysurf Mail <st...@gmail.com>.
2. notes
1. My current query is similiar to this
http://127.0.0.1:8983/solr/vault/select?q=ABCD&qf=Name+SKU&defType=edismax

2. I want it to be case insensitive




On Thu, Aug 8, 2013 at 2:52 PM, Mysurf Mail <st...@gmail.com> wrote:

> I have a documnet that contains the following data
>
> car {
>     id:     guid
>     name:   string
>     sku:   list<barcode>
> }
>
> Now, The barcodes dont have a pattern. It can be either one of the
> follwings:
>
> ABCD-EF34GD-JOHN
> ABCD-C08-YUVF
>
> I want to index my documents so that search for
> 1. ABCD will return both.
> 2. AB will return both.
> 3. JO - will return ABCD-EF34GD-JOHN but not car with name john.
>
> so far I have defined car and sku as text_en.
> But I dont get bulletes no 2 and 3.
> IS there a better way to define sku attribute.
> Thanks.
>