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 Joel Nylund <jn...@yahoo.com> on 2009/11/04 17:53:21 UTC

exact match lookup

Hi,

I have a field that I want to do exact match lookups using.
(when I say exact match, im looking for equivalent to a sql query  
where with no like clause so where feedClass = "Social News")

For example the field is called feedClass and im doing:

http://localhost:8983/solr/select?q=feedClass:Blog

http://localhost:8983/solr/select?q=feedClass:Social%20News

I tried using "text" and it seems to work pretty well except for  
classes with spaces in them.

So I tried using field type string, that didnt work. Then I tried  
defining a new type called:

      <fieldType name="text_nows" class="solr.TextField"  
positionIncrementGap="100">
     </fieldType>


This didnt seem to help either.

When I do these queries for this field with spaces, I seem to get  
random results

For example:

<response>
−
<lst name="responseHeader">
<int name="status">0</int>
<int name="QTime">5</int>
−
<lst name="params">
<str name="q">feedClass:Social News</str>
</lst>
</lst>
−
<result name="response" numFound="3451" start="0">
−
<doc>
<str name="feedClass">Blog</str>
<str name="firstLetterTitle">N</str>
</doc>


any ideas?

thanks
Joel


Re: exact match lookup

Posted by Paul Libbrecht <pa...@activemath.org>.
if you want to have exactly the same effect as the SQL equality, you  
need more.
The phrase query matches anything with words Social followed by news.
It would also match feedClass:"... finished. Social News In Our  
Bulletin".
As noted elsewhere on the thread you need to query this on a field  
thats' analyzed "little".

Having a "verbatim analyzer" could be the trick (is it good?).
Having an analyzer that puts start and end marks would also be the  
trick.

paul

Le 04-nov.-09 à 18:15, Jérôme Etévé a écrit :
> you need to quote your phrase when you search for 'Social News':
>
> feedClass:"Social News" (URI encoded of course).
>
> otherwise your request will become (I assume you're using a standard
> query parser) feedClass:Social defaultField:News . Well that's the
> idea.
>
> It should then work using the type string.
>
> Cheers!
>
> J.
>
>
> 2009/11/4 Joel Nylund <jn...@yahoo.com>:
>> Hi,
>>
>> I have a field that I want to do exact match lookups using.
>> (when I say exact match, im looking for equivalent to a sql query  
>> where with
>> no like clause so where feedClass = "Social News")
>>
>> For example the field is called feedClass and im doing:
>>
>> http://localhost:8983/solr/select?q=feedClass:Blog
>>
>> http://localhost:8983/solr/select?q=feedClass:Social%20News
>>
>> I tried using "text" and it seems to work pretty well except for  
>> classes
>> with spaces in them.
>>
>> So I tried using field type string, that didnt work. Then I tried  
>> defining a
>> new type called:
>>
>>    <fieldType name="text_nows" class="solr.TextField"
>> positionIncrementGap="100">
>>   </fieldType>
>>
>>
>> This didnt seem to help either.
>>
>> When I do these queries for this field with spaces, I seem to get  
>> random
>> results
>>
>> For example:
>>
>> <response>
>> −
>> <lst name="responseHeader">
>> <int name="status">0</int>
>> <int name="QTime">5</int>
>> −
>> <lst name="params">
>> <str name="q">feedClass:Social News</str>
>> </lst>
>> </lst>
>> −
>> <result name="response" numFound="3451" start="0">
>> −
>> <doc>
>> <str name="feedClass">Blog</str>
>> <str name="firstLetterTitle">N</str>
>> </doc>
>>
>>
>> any ideas?
>>
>> thanks
>> Joel
>>
>>
>
>
>
> -- 
> Jerome Eteve.
> http://www.eteve.net
> jerome@eteve.net


Re: exact match lookup

Posted by Erick Erickson <er...@gmail.com>.
How did you index your title field? It sholdn't be tokenized, see:
http://wiki.apache.org/solr/FAQ#Why_Isn.27t_Sorting_Working_on_my_Text_Fields.3F

<http://wiki.apache.org/solr/FAQ#Why_Isn.27t_Sorting_Working_on_my_Text_Fields.3F>
Best
Erick

On Wed, Nov 4, 2009 at 1:47 PM, Joel Nylund <jn...@yahoo.com> wrote:

> thank worked for me, changed to:
>
> http://localhost:8983/solr/select?q=feedClass:%22social%20news%22
>
> and the matches are correct, I changed the feedClass field back to type
> text.
>
> A followup question has to do with sorting these results.
>
> I have a field called title that I want the results sorted by.
>
>
> http://localhost:8983/solr/select?q=feedClass:%22social%20news%22&sort:title%20asc
>
> I tried this and the results are not sorted (they seem random)
>
> any ideas?
>
> thanks
> Joel
>
>
>
> <response>
> -
> <lst name="responseHeader">
> <int name="status">0</int>
> <int name="QTime">1</int>
> -
> <lst name="params">
> <str name="q">feedClass:"social news"</str>
> <str name="sort:title asc"/>
> </lst>
> </lst>
> -
> <result name="response" numFound="186" start="0">
> -
> <doc>
> <str name="feedClass">Social News</str>
> <str name="firstLetterTitle">F</str>
> <str name="title">Far</str>
> </doc>
> <doc>
> <str name="feedClass">Social News</str>
> <str name="firstLetterTitle">D</str>
> <str name="title">dig</str>
> </doc>
> <doc>
> <str name="feedClass">Social News</str>
> <str name="firstLetterTitle">T</str>
> <str name="title">Tech</str>
> </doc>
> <doc>
> <str name="feedClass">Social News</str>
> <str name="firstLetterTitle">M</str>
> <str name="title">Mix</str>
> </doc>
>
>
>
>
> On Nov 4, 2009, at 12:15 PM, Jérôme Etévé wrote:
>
>  Hi,
>> you need to quote your phrase when you search for 'Social News':
>>
>> feedClass:"Social News" (URI encoded of course).
>>
>> otherwise your request will become (I assume you're using a standard
>> query parser) feedClass:Social defaultField:News . Well that's the
>> idea.
>>
>> It should then work using the type string.
>>
>> Cheers!
>>
>> J.
>>
>>
>> 2009/11/4 Joel Nylund <jn...@yahoo.com>:
>>
>>> Hi,
>>>
>>> I have a field that I want to do exact match lookups using.
>>> (when I say exact match, im looking for equivalent to a sql query where
>>> with
>>> no like clause so where feedClass = "Social News")
>>>
>>> For example the field is called feedClass and im doing:
>>>
>>> http://localhost:8983/solr/select?q=feedClass:Blog
>>>
>>> http://localhost:8983/solr/select?q=feedClass:Social%20News
>>>
>>> I tried using "text" and it seems to work pretty well except for classes
>>> with spaces in them.
>>>
>>> So I tried using field type string, that didnt work. Then I tried
>>> defining a
>>> new type called:
>>>
>>>   <fieldType name="text_nows" class="solr.TextField"
>>> positionIncrementGap="100">
>>>  </fieldType>
>>>
>>>
>>> This didnt seem to help either.
>>>
>>> When I do these queries for this field with spaces, I seem to get random
>>> results
>>>
>>> For example:
>>>
>>> <response>
>>> -
>>> <lst name="responseHeader">
>>> <int name="status">0</int>
>>> <int name="QTime">5</int>
>>> -
>>> <lst name="params">
>>> <str name="q">feedClass:Social News</str>
>>> </lst>
>>> </lst>
>>> -
>>> <result name="response" numFound="3451" start="0">
>>> -
>>> <doc>
>>> <str name="feedClass">Blog</str>
>>> <str name="firstLetterTitle">N</str>
>>> </doc>
>>>
>>>
>>> any ideas?
>>>
>>> thanks
>>> Joel
>>>
>>>
>>>
>>
>>
>> --
>> Jerome Eteve.
>> http://www.eteve.net
>> jerome@eteve.net
>>
>
>

Re: exact match lookup

Posted by Joel Nylund <jn...@yahoo.com>.
that worked, thanks!

had to negate the score.

thanks
Joel

On Nov 4, 2009, at 1:57 PM, Jérôme Etévé wrote:

> If feedClass acts as an identifier, better use string :)
>
> use sort=title asc,score desc (not sort:)
>
> J.
>
> 2009/11/4 Joel Nylund <jn...@yahoo.com>:
>> thank worked for me, changed to:
>>
>> http://localhost:8983/solr/select?q=feedClass:%22social%20news%22
>>
>> and the matches are correct, I changed the feedClass field back to  
>> type
>> text.
>>
>> A followup question has to do with sorting these results.
>>
>> I have a field called title that I want the results sorted by.
>>
>> http://localhost:8983/solr/select?q=feedClass:%22social%20news%22&sort:title%20asc
>>
>> I tried this and the results are not sorted (they seem random)
>>
>> any ideas?
>>
>> thanks
>> Joel
>>
>>
>> <response>
>> −
>> <lst name="responseHeader">
>> <int name="status">0</int>
>> <int name="QTime">1</int>
>> −
>> <lst name="params">
>> <str name="q">feedClass:"social news"</str>
>> <str name="sort:title asc"/>
>> </lst>
>> </lst>
>> −
>> <result name="response" numFound="186" start="0">
>> −
>> <doc>
>> <str name="feedClass">Social News</str>
>> <str name="firstLetterTitle">F</str>
>> <str name="title">Far</str>
>> </doc>
>> <doc>
>> <str name="feedClass">Social News</str>
>> <str name="firstLetterTitle">D</str>
>> <str name="title">dig</str>
>> </doc>
>> <doc>
>> <str name="feedClass">Social News</str>
>> <str name="firstLetterTitle">T</str>
>> <str name="title">Tech</str>
>> </doc>
>> <doc>
>> <str name="feedClass">Social News</str>
>> <str name="firstLetterTitle">M</str>
>> <str name="title">Mix</str>
>> </doc>
>>
>>
>>
>> On Nov 4, 2009, at 12:15 PM, Jérôme Etévé wrote:
>>
>>> Hi,
>>> you need to quote your phrase when you search for 'Social News':
>>>
>>> feedClass:"Social News" (URI encoded of course).
>>>
>>> otherwise your request will become (I assume you're using a standard
>>> query parser) feedClass:Social defaultField:News . Well that's the
>>> idea.
>>>
>>> It should then work using the type string.
>>>
>>> Cheers!
>>>
>>> J.
>>>
>>>
>>> 2009/11/4 Joel Nylund <jn...@yahoo.com>:
>>>>
>>>> Hi,
>>>>
>>>> I have a field that I want to do exact match lookups using.
>>>> (when I say exact match, im looking for equivalent to a sql query  
>>>> where
>>>> with
>>>> no like clause so where feedClass = "Social News")
>>>>
>>>> For example the field is called feedClass and im doing:
>>>>
>>>> http://localhost:8983/solr/select?q=feedClass:Blog
>>>>
>>>> http://localhost:8983/solr/select?q=feedClass:Social%20News
>>>>
>>>> I tried using "text" and it seems to work pretty well except for  
>>>> classes
>>>> with spaces in them.
>>>>
>>>> So I tried using field type string, that didnt work. Then I tried
>>>> defining a
>>>> new type called:
>>>>
>>>>  <fieldType name="text_nows" class="solr.TextField"
>>>> positionIncrementGap="100">
>>>> </fieldType>
>>>>
>>>>
>>>> This didnt seem to help either.
>>>>
>>>> When I do these queries for this field with spaces, I seem to get  
>>>> random
>>>> results
>>>>
>>>> For example:
>>>>
>>>> <response>
>>>> −
>>>> <lst name="responseHeader">
>>>> <int name="status">0</int>
>>>> <int name="QTime">5</int>
>>>> −
>>>> <lst name="params">
>>>> <str name="q">feedClass:Social News</str>
>>>> </lst>
>>>> </lst>
>>>> −
>>>> <result name="response" numFound="3451" start="0">
>>>> −
>>>> <doc>
>>>> <str name="feedClass">Blog</str>
>>>> <str name="firstLetterTitle">N</str>
>>>> </doc>
>>>>
>>>>
>>>> any ideas?
>>>>
>>>> thanks
>>>> Joel
>>>>
>>>>
>>>
>>>
>>>
>>> --
>>> Jerome Eteve.
>>> http://www.eteve.net
>>> jerome@eteve.net
>>
>>
>
>
>
> -- 
> Jerome Eteve.
> http://www.eteve.net
> jerome@eteve.net


Re: exact match lookup

Posted by Jérôme Etévé <je...@gmail.com>.
If feedClass acts as an identifier, better use string :)

use sort=title asc,score desc (not sort:)

J.

2009/11/4 Joel Nylund <jn...@yahoo.com>:
> thank worked for me, changed to:
>
> http://localhost:8983/solr/select?q=feedClass:%22social%20news%22
>
> and the matches are correct, I changed the feedClass field back to type
> text.
>
> A followup question has to do with sorting these results.
>
> I have a field called title that I want the results sorted by.
>
> http://localhost:8983/solr/select?q=feedClass:%22social%20news%22&sort:title%20asc
>
> I tried this and the results are not sorted (they seem random)
>
> any ideas?
>
> thanks
> Joel
>
>
> <response>
> −
> <lst name="responseHeader">
> <int name="status">0</int>
> <int name="QTime">1</int>
> −
> <lst name="params">
> <str name="q">feedClass:"social news"</str>
> <str name="sort:title asc"/>
> </lst>
> </lst>
> −
> <result name="response" numFound="186" start="0">
> −
> <doc>
> <str name="feedClass">Social News</str>
> <str name="firstLetterTitle">F</str>
> <str name="title">Far</str>
> </doc>
> <doc>
> <str name="feedClass">Social News</str>
> <str name="firstLetterTitle">D</str>
> <str name="title">dig</str>
> </doc>
> <doc>
> <str name="feedClass">Social News</str>
> <str name="firstLetterTitle">T</str>
> <str name="title">Tech</str>
> </doc>
> <doc>
> <str name="feedClass">Social News</str>
> <str name="firstLetterTitle">M</str>
> <str name="title">Mix</str>
> </doc>
>
>
>
> On Nov 4, 2009, at 12:15 PM, Jérôme Etévé wrote:
>
>> Hi,
>> you need to quote your phrase when you search for 'Social News':
>>
>> feedClass:"Social News" (URI encoded of course).
>>
>> otherwise your request will become (I assume you're using a standard
>> query parser) feedClass:Social defaultField:News . Well that's the
>> idea.
>>
>> It should then work using the type string.
>>
>> Cheers!
>>
>> J.
>>
>>
>> 2009/11/4 Joel Nylund <jn...@yahoo.com>:
>>>
>>> Hi,
>>>
>>> I have a field that I want to do exact match lookups using.
>>> (when I say exact match, im looking for equivalent to a sql query where
>>> with
>>> no like clause so where feedClass = "Social News")
>>>
>>> For example the field is called feedClass and im doing:
>>>
>>> http://localhost:8983/solr/select?q=feedClass:Blog
>>>
>>> http://localhost:8983/solr/select?q=feedClass:Social%20News
>>>
>>> I tried using "text" and it seems to work pretty well except for classes
>>> with spaces in them.
>>>
>>> So I tried using field type string, that didnt work. Then I tried
>>> defining a
>>> new type called:
>>>
>>>   <fieldType name="text_nows" class="solr.TextField"
>>> positionIncrementGap="100">
>>>  </fieldType>
>>>
>>>
>>> This didnt seem to help either.
>>>
>>> When I do these queries for this field with spaces, I seem to get random
>>> results
>>>
>>> For example:
>>>
>>> <response>
>>> −
>>> <lst name="responseHeader">
>>> <int name="status">0</int>
>>> <int name="QTime">5</int>
>>> −
>>> <lst name="params">
>>> <str name="q">feedClass:Social News</str>
>>> </lst>
>>> </lst>
>>> −
>>> <result name="response" numFound="3451" start="0">
>>> −
>>> <doc>
>>> <str name="feedClass">Blog</str>
>>> <str name="firstLetterTitle">N</str>
>>> </doc>
>>>
>>>
>>> any ideas?
>>>
>>> thanks
>>> Joel
>>>
>>>
>>
>>
>>
>> --
>> Jerome Eteve.
>> http://www.eteve.net
>> jerome@eteve.net
>
>



-- 
Jerome Eteve.
http://www.eteve.net
jerome@eteve.net

Re: exact match lookup

Posted by AHMET ARSLAN <io...@yahoo.com>.
> A followup question has to do with sorting these results.
> 
> I have a field called title that I want the results sorted
> by.
> 
> http://localhost:8983/solr/select?q=feedClass:%22social%20news%22&sort:title%20asc
> 
> I tried this and the results are not sorted (they seem
> random)
> 
> any ideas?

Sort syntax [1] uses equal sign, not semicolon. try this &sort=title+asc

[1]http://wiki.apache.org/solr/CommonQueryParameters#sort

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

Re: exact match lookup

Posted by Joel Nylund <jn...@yahoo.com>.
thank worked for me, changed to:

http://localhost:8983/solr/select?q=feedClass:%22social%20news%22

and the matches are correct, I changed the feedClass field back to  
type text.

A followup question has to do with sorting these results.

I have a field called title that I want the results sorted by.

http://localhost:8983/solr/select?q=feedClass:%22social%20news%22&sort:title%20asc

I tried this and the results are not sorted (they seem random)

any ideas?

thanks
Joel


<response>
−
<lst name="responseHeader">
<int name="status">0</int>
<int name="QTime">1</int>
−
<lst name="params">
<str name="q">feedClass:"social news"</str>
<str name="sort:title asc"/>
</lst>
</lst>
−
<result name="response" numFound="186" start="0">
−
<doc>
<str name="feedClass">Social News</str>
<str name="firstLetterTitle">F</str>
<str name="title">Far</str>
</doc>
<doc>
<str name="feedClass">Social News</str>
<str name="firstLetterTitle">D</str>
<str name="title">dig</str>
</doc>
<doc>
<str name="feedClass">Social News</str>
<str name="firstLetterTitle">T</str>
<str name="title">Tech</str>
</doc>
<doc>
<str name="feedClass">Social News</str>
<str name="firstLetterTitle">M</str>
<str name="title">Mix</str>
</doc>



On Nov 4, 2009, at 12:15 PM, Jérôme Etévé wrote:

> Hi,
> you need to quote your phrase when you search for 'Social News':
>
> feedClass:"Social News" (URI encoded of course).
>
> otherwise your request will become (I assume you're using a standard
> query parser) feedClass:Social defaultField:News . Well that's the
> idea.
>
> It should then work using the type string.
>
> Cheers!
>
> J.
>
>
> 2009/11/4 Joel Nylund <jn...@yahoo.com>:
>> Hi,
>>
>> I have a field that I want to do exact match lookups using.
>> (when I say exact match, im looking for equivalent to a sql query  
>> where with
>> no like clause so where feedClass = "Social News")
>>
>> For example the field is called feedClass and im doing:
>>
>> http://localhost:8983/solr/select?q=feedClass:Blog
>>
>> http://localhost:8983/solr/select?q=feedClass:Social%20News
>>
>> I tried using "text" and it seems to work pretty well except for  
>> classes
>> with spaces in them.
>>
>> So I tried using field type string, that didnt work. Then I tried  
>> defining a
>> new type called:
>>
>>    <fieldType name="text_nows" class="solr.TextField"
>> positionIncrementGap="100">
>>   </fieldType>
>>
>>
>> This didnt seem to help either.
>>
>> When I do these queries for this field with spaces, I seem to get  
>> random
>> results
>>
>> For example:
>>
>> <response>
>> −
>> <lst name="responseHeader">
>> <int name="status">0</int>
>> <int name="QTime">5</int>
>> −
>> <lst name="params">
>> <str name="q">feedClass:Social News</str>
>> </lst>
>> </lst>
>> −
>> <result name="response" numFound="3451" start="0">
>> −
>> <doc>
>> <str name="feedClass">Blog</str>
>> <str name="firstLetterTitle">N</str>
>> </doc>
>>
>>
>> any ideas?
>>
>> thanks
>> Joel
>>
>>
>
>
>
> -- 
> Jerome Eteve.
> http://www.eteve.net
> jerome@eteve.net


Re: exact match lookup

Posted by Jérôme Etévé <je...@gmail.com>.
Hi,
 you need to quote your phrase when you search for 'Social News':

feedClass:"Social News" (URI encoded of course).

otherwise your request will become (I assume you're using a standard
query parser) feedClass:Social defaultField:News . Well that's the
idea.

It should then work using the type string.

Cheers!

J.


2009/11/4 Joel Nylund <jn...@yahoo.com>:
> Hi,
>
> I have a field that I want to do exact match lookups using.
> (when I say exact match, im looking for equivalent to a sql query where with
> no like clause so where feedClass = "Social News")
>
> For example the field is called feedClass and im doing:
>
> http://localhost:8983/solr/select?q=feedClass:Blog
>
> http://localhost:8983/solr/select?q=feedClass:Social%20News
>
> I tried using "text" and it seems to work pretty well except for classes
> with spaces in them.
>
> So I tried using field type string, that didnt work. Then I tried defining a
> new type called:
>
>     <fieldType name="text_nows" class="solr.TextField"
> positionIncrementGap="100">
>    </fieldType>
>
>
> This didnt seem to help either.
>
> When I do these queries for this field with spaces, I seem to get random
> results
>
> For example:
>
> <response>
> −
> <lst name="responseHeader">
> <int name="status">0</int>
> <int name="QTime">5</int>
> −
> <lst name="params">
> <str name="q">feedClass:Social News</str>
> </lst>
> </lst>
> −
> <result name="response" numFound="3451" start="0">
> −
> <doc>
> <str name="feedClass">Blog</str>
> <str name="firstLetterTitle">N</str>
> </doc>
>
>
> any ideas?
>
> thanks
> Joel
>
>



-- 
Jerome Eteve.
http://www.eteve.net
jerome@eteve.net