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 Antonio Zippo <re...@yahoo.it> on 2009/01/26 20:15:44 UTC

exact field match

Hi all,

i'm using a string field named "myField"
and 2 documents containing:
1. myField="my name is james bond"
2. myField="james bond"

if i use a query like this: 
myField:"james bond" it returns 2 documents....

how can i get only the second document using a string or text field? I need to search the document with the exact value....nor documents containing the exact phrase in value

thanks in advance


      

Re: exact field match

Posted by Svein Parnas <sv...@parnas.no>.
Another solution is to put a special token in front and end of every  
occurence of the field, eg aastartaa in front an zzendzz in the end (a  
solution looking like Fasts boundary match feature behind the hood),  
You could then search for exact match ("aastartaa your phrase  
zzendzz"), and you would also get support for 'begins  
with' ("aastartaa your phrase"), 'ends with' ("your phrase zzendzz")  
and, if you need it, boosting of short field values ("aastartaa your  
phrase zzendzz"~10000) - a feature several others have been asking for  
earlier on on this list.

Svein

On 26. jan.. 2009, at 20.29, Erick Erickson wrote:

> You need to index and search using something like
> KeywordAnalyzer. That analyzer does no tokenizing/
> data transformation or such. For instance, it
> doesn't fold case.
>
> You will be unable to search for "bond" and get a hit
> in this case, so one solution is to use two fields, and
> search one or the other depending upon your needs.
> e.g.
> myField
> myFieldTokenized
>
> Each field gets a complete copy of the data, and you search
> "myField" in the case you're describing and
> myFieldTokenized when you want to match on "bond".
>
> Of course, if you never want a hit on "bond", you don't need the
> Tokenized field.
>
> Best
> Erick
>
> On Mon, Jan 26, 2009 at 2:15 PM, Antonio Zippo <re...@yahoo.it>  
> wrote:
>
>> Hi all,
>>
>> i'm using a string field named "myField"
>> and 2 documents containing:
>> 1. myField="my name is james bond"
>> 2. myField="james bond"
>>
>> if i use a query like this:
>> myField:"james bond" it returns 2 documents....
>>
>> how can i get only the second document using a string or text  
>> field? I need
>> to search the document with the exact value....nor documents  
>> containing the
>> exact phrase in value
>>
>> thanks in advance
>>
>>
>>


Re: exact field match

Posted by Antonio Zippo <re...@yahoo.it>.
it works...

thanks for your help....

bye




________________________________
Da: Erick Erickson <er...@gmail.com>
A: solr-user@lucene.apache.org
Inviato: Lunedì 26 gennaio 2009, 20:29:17
Oggetto: Re: exact field match

You need to index and search using something like
KeywordAnalyzer. That analyzer does no tokenizing/
data transformation or such. For instance, it
doesn't fold case.

You will be unable to search for "bond" and get a hit
in this case, so one solution is to use two fields, and
search one or the other depending upon your needs.
e.g.
myField
myFieldTokenized

Each field gets a complete copy of the data, and you search
"myField" in the case you're describing and
myFieldTokenized when you want to match on "bond".

Of course, if you never want a hit on "bond", you don't need the
Tokenized field.

Best
Erick

On Mon, Jan 26, 2009 at 2:15 PM, Antonio Zippo <re...@yahoo.it> wrote:

> Hi all,
>
> i'm using a string field named "myField"
> and 2 documents containing:
> 1. myField="my name is james bond"
> 2. myField="james bond"
>
> if i use a query like this:
> myField:"james bond" it returns 2 documents....
>
> how can i get only the second document using a string or text field? I need
> to search the document with the exact value....nor documents containing the
> exact phrase in value
>
> thanks in advance
>
>
>



      

Re: exact field match

Posted by Erick Erickson <er...@gmail.com>.
You need to index and search using something like
KeywordAnalyzer. That analyzer does no tokenizing/
data transformation or such. For instance, it
doesn't fold case.

You will be unable to search for "bond" and get a hit
in this case, so one solution is to use two fields, and
search one or the other depending upon your needs.
e.g.
myField
myFieldTokenized

Each field gets a complete copy of the data, and you search
"myField" in the case you're describing and
myFieldTokenized when you want to match on "bond".

Of course, if you never want a hit on "bond", you don't need the
Tokenized field.

Best
Erick

On Mon, Jan 26, 2009 at 2:15 PM, Antonio Zippo <re...@yahoo.it> wrote:

> Hi all,
>
> i'm using a string field named "myField"
> and 2 documents containing:
> 1. myField="my name is james bond"
> 2. myField="james bond"
>
> if i use a query like this:
> myField:"james bond" it returns 2 documents....
>
> how can i get only the second document using a string or text field? I need
> to search the document with the exact value....nor documents containing the
> exact phrase in value
>
> thanks in advance
>
>
>