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 Chamnap Chhorn <ch...@gmail.com> on 2010/11/17 04:28:22 UTC

Must require quote with single word token query?

I have one question related to single word token with dismax query. In order
to be found I need to add the quote around the search query all the time.
This is quite hard for me to do since it is part of full text search.

Here is my solr query and field type definition (Solr 1.4):
    <fieldType name="text_keyword" class="solr.TextField"
positionIncrementGap="100">
      <analyzer>
        <tokenizer class="solr.KeywordTokenizerFactory"/>
        <filter class="solr.LowerCaseFilterFactory" />
        <filter class="solr.TrimFilterFactory" />
        <filter class="solr.StopFilterFactory" ignoreCase="true"
words="stopwords.txt" enablePositionIncrements="true"/>
        <filter class="solr.SynonymFilterFactory" synonyms="synonyms.txt"
ignoreCase="true" expand="false" />
        <filter class="solr.RemoveDuplicatesTokenFilterFactory"/>
      </analyzer>
    </fieldType>

    <field name="keyphrase" type="text_keyword" indexed="true"
stored="false" multiValued="true"/>

With this query q=smart%20mobile&qf=keyphrase&debugQuery=on&defType=dismax,
solr returns nothing. However, with quote on the search query q="smart
mobile"&qf=keyphrase&debugQuery=on&defType=dismax, the result is found.

Is it a must to use quote for a single word token field?

-- 
Chhorn Chamnap
http://chamnapchhorn.blogspot.com/

Re: Must require quote with single word token query?

Posted by Chamnap Chhorn <ch...@gmail.com>.
Very late reply, actually.

I can't manage it to work with local params using my text_keyword field and
multi word query. What i do to achieve is to do full text searching. If the
query matches the keyphrase, it will be in higher position.

Are they other ways to work around?

On Wed, Nov 24, 2010 at 9:13 PM, Jonathan Rochkind <ro...@jhu.edu> wrote:

> Okay, we need to take a step back and think about what you are trying to
> do.
>
> Reading back in the thread and looking at your schema, you have a
> non-tokenized field whose terms can include whitespace.  There is in fact no
> good way to use that with dismax, dismax doesn't work that way. What you can
> do as Yonik suggests is use the 'field' query parser instead.  You can force
> the use of the 'field' query parser with 'local params', or you can even
> create a combined query with uses 'field' for one clause and 'dismax' for
> another, with nested query syntax.
>
> But every individual part of your query can only use one query parser at a
> time, there's no way to use both at once.
>
> But if you want to use that request handler, but force it to use 'field'
> _instead_, that can be easily done:
>
> &q=multi word query&defType=field&v=field_name
>
> You don't even need 'local params', although you can also do it with 'local
> params': &q={!field v=field_name}
>
> That's it. (except all those values need to be URI encoded).  But it won't
> be using dismax anymore, although it'll be using that request handler you
> have set up to default to dismax, you're telling it to use 'field' this time
> anyway.
>
> If that doesn't do what you want, why don't you take a step back and tell
> us what query behavior you are actually trying to create, and maybe someone
> can give you some ideas for accomplishing it.
>
> ________________________________________
> From: Chamnap Chhorn [chamnapchhorn@gmail.com]
> Sent: Wednesday, November 24, 2010 4:43 AM
> To: yonik@lucidimagination.com
> Cc: solr-user@lucene.apache.org
> Subject: Re: Must require quote with single word token query?
>
> I've looked at solr local params. However, I can't figure out how to
> integrate it with my full text search using dismax handler. Here is my full
> text search request handler.
>
>  <requestHandler name="mb_listings" class="solr.SearchHandler">
>    <lst name="defaults">
>      <str name="echoParams">explicit</str>
>      <int name="rows">20</int>
>      <str name="defType">dismax</str>
>      <str name="qf">name_ngram^20 name^40 postal_code address description
> long_description location keyphrase short_description category telephone
> email website</str>
>      <str name="pf">name_ngram</str>
>      <str name="bf">fap^10</str>
>      <str name="fl">uuid</str>
>      <str name="version">2.2</str>
>      <str name="indent">on</str>
>      <str name="tie">0.1</str>
>    </lst>
>    <lst name="appends">
>      <str name="fq">type:Listing</str>
>    </lst>
>    <lst name="invariants">
>      <str name="facet">false</str>
>    </lst>
>    <arr name="last-components">
>      <str>spellcheck</str>
>      <str>elevateListings</str>
>    </arr>
>  </requestHandler>
>
> Note: postal_code, keyphrase, category, telephone, email, website has field
> type "text_keyword".
>
> Thanks
> On Sat, Nov 20, 2010 at 9:49 AM, Yonik Seeley <yonik@lucidimagination.com
> >wrote:
>
> > On Fri, Nov 19, 2010 at 9:41 PM, Chamnap Chhorn <chamnapchhorn@gmail.com
> >
> > wrote:
> > > Wow, i never know this syntax before. What's that called?
> >
> > I dubbed it "local params" since it adds local info to a parameter
> > (think extra metadata, like XML attributes on an element).
> >
> > http://wiki.apache.org/solr/LocalParams
> >
> > It's used mostly to invoke different query parsers, but it's also used
> > to add extra metadata to faceting commands too (and is required for
> > stuff like multi-select faceting):
> >
> >
> >
> http://wiki.apache.org/solr/SimpleFacetParameters#Multi-Select_Faceting_and_LocalParams
> >
> >
> > -Yonik
> > http://www.lucidimagination.com
> >
> >
> >
> > > On 11/19/10, Yonik Seeley <yo...@lucidimagination.com> wrote:
> > >> On Tue, Nov 16, 2010 at 10:28 PM, Chamnap Chhorn
> > >> <ch...@gmail.com> wrote:
> > >>> I have one question related to single word token with dismax query.
> In
> > >>> order
> > >>> to be found I need to add the quote around the search query all the
> > time.
> > >>> This is quite hard for me to do since it is part of full text search.
> > >>>
> > >>> Here is my solr query and field type definition (Solr 1.4):
> > >>>    <fieldType name="text_keyword" class="solr.TextField"
> > >>> positionIncrementGap="100">
> > >>>      <analyzer>
> > >>>        <tokenizer class="solr.KeywordTokenizerFactory"/>
> > >>>        <filter class="solr.LowerCaseFilterFactory" />
> > >>>        <filter class="solr.TrimFilterFactory" />
> > >>>        <filter class="solr.StopFilterFactory" ignoreCase="true"
> > >>> words="stopwords.txt" enablePositionIncrements="true"/>
> > >>>        <filter class="solr.SynonymFilterFactory"
> > synonyms="synonyms.txt"
> > >>> ignoreCase="true" expand="false" />
> > >>>        <filter class="solr.RemoveDuplicatesTokenFilterFactory"/>
> > >>>      </analyzer>
> > >>>    </fieldType>
> > >>>
> > >>>    <field name="keyphrase" type="text_keyword" indexed="true"
> > >>> stored="false" multiValued="true"/>
> > >>>
> > >>> With this query
> > >>> q=smart%20mobile&qf=keyphrase&debugQuery=on&defType=dismax,
> > >>> solr returns nothing. However, with quote on the search query
> q="smart
> > >>> mobile"&qf=keyphrase&debugQuery=on&defType=dismax, the result is
> found.
> > >>>
> > >>> Is it a must to use quote for a single word token field?
> > >>
> > >> Yes, you must currently quote tokens if they contain whitespace -
> > >> otherwise the query parser first breaks on whitespace before doing
> > >> analysis on each part separately.
> > >>
> > >> Using dismax is an odd choice if you are only querying on keyphrase
> > though.
> > >> You might look at the field query parser - it is a basic single-field
> > >> single-value parser with no operators (hence no need to escape any
> > >> special characters).
> > >>
> > >> q={!field f=keyphrase}smart%20mobile
> > >>
> > >> or you can decompose it using param dereferencing (sometimes easier to
> > >> construct)
> > >>
> > >> q={!field f=keyphrase v=$qq}&qq=smart%20mobile
> > >>
> > >> -Yonik
> > >> http://www.lucidimagination.com
> > >>
> > >
> > > --
> > > Sent from my mobile device
> > >
> > > Chhorn Chamnap
> > > http://chamnapchhorn.blogspot.com/
> > >
> >
>
>
>
> --
> Chhorn Chamnap
> http://chamnapchhorn.blogspot.com/
>



-- 
Chhorn Chamnap
http://chamnapchhorn.blogspot.com/

RE: Must require quote with single word token query?

Posted by Jonathan Rochkind <ro...@jhu.edu>.
Okay, we need to take a step back and think about what you are trying to do. 

Reading back in the thread and looking at your schema, you have a non-tokenized field whose terms can include whitespace.  There is in fact no good way to use that with dismax, dismax doesn't work that way. What you can do as Yonik suggests is use the 'field' query parser instead.  You can force the use of the 'field' query parser with 'local params', or you can even create a combined query with uses 'field' for one clause and 'dismax' for another, with nested query syntax. 

But every individual part of your query can only use one query parser at a time, there's no way to use both at once. 

But if you want to use that request handler, but force it to use 'field' _instead_, that can be easily done:

&q=multi word query&defType=field&v=field_name

You don't even need 'local params', although you can also do it with 'local params': &q={!field v=field_name}

That's it. (except all those values need to be URI encoded).  But it won't be using dismax anymore, although it'll be using that request handler you have set up to default to dismax, you're telling it to use 'field' this time anyway. 

If that doesn't do what you want, why don't you take a step back and tell us what query behavior you are actually trying to create, and maybe someone can give you some ideas for accomplishing it. 

________________________________________
From: Chamnap Chhorn [chamnapchhorn@gmail.com]
Sent: Wednesday, November 24, 2010 4:43 AM
To: yonik@lucidimagination.com
Cc: solr-user@lucene.apache.org
Subject: Re: Must require quote with single word token query?

I've looked at solr local params. However, I can't figure out how to
integrate it with my full text search using dismax handler. Here is my full
text search request handler.

  <requestHandler name="mb_listings" class="solr.SearchHandler">
    <lst name="defaults">
      <str name="echoParams">explicit</str>
      <int name="rows">20</int>
      <str name="defType">dismax</str>
      <str name="qf">name_ngram^20 name^40 postal_code address description
long_description location keyphrase short_description category telephone
email website</str>
      <str name="pf">name_ngram</str>
      <str name="bf">fap^10</str>
      <str name="fl">uuid</str>
      <str name="version">2.2</str>
      <str name="indent">on</str>
      <str name="tie">0.1</str>
    </lst>
    <lst name="appends">
      <str name="fq">type:Listing</str>
    </lst>
    <lst name="invariants">
      <str name="facet">false</str>
    </lst>
    <arr name="last-components">
      <str>spellcheck</str>
      <str>elevateListings</str>
    </arr>
  </requestHandler>

Note: postal_code, keyphrase, category, telephone, email, website has field
type "text_keyword".

Thanks
On Sat, Nov 20, 2010 at 9:49 AM, Yonik Seeley <yo...@lucidimagination.com>wrote:

> On Fri, Nov 19, 2010 at 9:41 PM, Chamnap Chhorn <ch...@gmail.com>
> wrote:
> > Wow, i never know this syntax before. What's that called?
>
> I dubbed it "local params" since it adds local info to a parameter
> (think extra metadata, like XML attributes on an element).
>
> http://wiki.apache.org/solr/LocalParams
>
> It's used mostly to invoke different query parsers, but it's also used
> to add extra metadata to faceting commands too (and is required for
> stuff like multi-select faceting):
>
>
> http://wiki.apache.org/solr/SimpleFacetParameters#Multi-Select_Faceting_and_LocalParams
>
>
> -Yonik
> http://www.lucidimagination.com
>
>
>
> > On 11/19/10, Yonik Seeley <yo...@lucidimagination.com> wrote:
> >> On Tue, Nov 16, 2010 at 10:28 PM, Chamnap Chhorn
> >> <ch...@gmail.com> wrote:
> >>> I have one question related to single word token with dismax query. In
> >>> order
> >>> to be found I need to add the quote around the search query all the
> time.
> >>> This is quite hard for me to do since it is part of full text search.
> >>>
> >>> Here is my solr query and field type definition (Solr 1.4):
> >>>    <fieldType name="text_keyword" class="solr.TextField"
> >>> positionIncrementGap="100">
> >>>      <analyzer>
> >>>        <tokenizer class="solr.KeywordTokenizerFactory"/>
> >>>        <filter class="solr.LowerCaseFilterFactory" />
> >>>        <filter class="solr.TrimFilterFactory" />
> >>>        <filter class="solr.StopFilterFactory" ignoreCase="true"
> >>> words="stopwords.txt" enablePositionIncrements="true"/>
> >>>        <filter class="solr.SynonymFilterFactory"
> synonyms="synonyms.txt"
> >>> ignoreCase="true" expand="false" />
> >>>        <filter class="solr.RemoveDuplicatesTokenFilterFactory"/>
> >>>      </analyzer>
> >>>    </fieldType>
> >>>
> >>>    <field name="keyphrase" type="text_keyword" indexed="true"
> >>> stored="false" multiValued="true"/>
> >>>
> >>> With this query
> >>> q=smart%20mobile&qf=keyphrase&debugQuery=on&defType=dismax,
> >>> solr returns nothing. However, with quote on the search query q="smart
> >>> mobile"&qf=keyphrase&debugQuery=on&defType=dismax, the result is found.
> >>>
> >>> Is it a must to use quote for a single word token field?
> >>
> >> Yes, you must currently quote tokens if they contain whitespace -
> >> otherwise the query parser first breaks on whitespace before doing
> >> analysis on each part separately.
> >>
> >> Using dismax is an odd choice if you are only querying on keyphrase
> though.
> >> You might look at the field query parser - it is a basic single-field
> >> single-value parser with no operators (hence no need to escape any
> >> special characters).
> >>
> >> q={!field f=keyphrase}smart%20mobile
> >>
> >> or you can decompose it using param dereferencing (sometimes easier to
> >> construct)
> >>
> >> q={!field f=keyphrase v=$qq}&qq=smart%20mobile
> >>
> >> -Yonik
> >> http://www.lucidimagination.com
> >>
> >
> > --
> > Sent from my mobile device
> >
> > Chhorn Chamnap
> > http://chamnapchhorn.blogspot.com/
> >
>



--
Chhorn Chamnap
http://chamnapchhorn.blogspot.com/

Re: Must require quote with single word token query?

Posted by Chamnap Chhorn <ch...@gmail.com>.
I've looked at solr local params. However, I can't figure out how to
integrate it with my full text search using dismax handler. Here is my full
text search request handler.

  <requestHandler name="mb_listings" class="solr.SearchHandler">
    <lst name="defaults">
      <str name="echoParams">explicit</str>
      <int name="rows">20</int>
      <str name="defType">dismax</str>
      <str name="qf">name_ngram^20 name^40 postal_code address description
long_description location keyphrase short_description category telephone
email website</str>
      <str name="pf">name_ngram</str>
      <str name="bf">fap^10</str>
      <str name="fl">uuid</str>
      <str name="version">2.2</str>
      <str name="indent">on</str>
      <str name="tie">0.1</str>
    </lst>
    <lst name="appends">
      <str name="fq">type:Listing</str>
    </lst>
    <lst name="invariants">
      <str name="facet">false</str>
    </lst>
    <arr name="last-components">
      <str>spellcheck</str>
      <str>elevateListings</str>
    </arr>
  </requestHandler>

Note: postal_code, keyphrase, category, telephone, email, website has field
type "text_keyword".

Thanks
On Sat, Nov 20, 2010 at 9:49 AM, Yonik Seeley <yo...@lucidimagination.com>wrote:

> On Fri, Nov 19, 2010 at 9:41 PM, Chamnap Chhorn <ch...@gmail.com>
> wrote:
> > Wow, i never know this syntax before. What's that called?
>
> I dubbed it "local params" since it adds local info to a parameter
> (think extra metadata, like XML attributes on an element).
>
> http://wiki.apache.org/solr/LocalParams
>
> It's used mostly to invoke different query parsers, but it's also used
> to add extra metadata to faceting commands too (and is required for
> stuff like multi-select faceting):
>
>
> http://wiki.apache.org/solr/SimpleFacetParameters#Multi-Select_Faceting_and_LocalParams
>
>
> -Yonik
> http://www.lucidimagination.com
>
>
>
> > On 11/19/10, Yonik Seeley <yo...@lucidimagination.com> wrote:
> >> On Tue, Nov 16, 2010 at 10:28 PM, Chamnap Chhorn
> >> <ch...@gmail.com> wrote:
> >>> I have one question related to single word token with dismax query. In
> >>> order
> >>> to be found I need to add the quote around the search query all the
> time.
> >>> This is quite hard for me to do since it is part of full text search.
> >>>
> >>> Here is my solr query and field type definition (Solr 1.4):
> >>>    <fieldType name="text_keyword" class="solr.TextField"
> >>> positionIncrementGap="100">
> >>>      <analyzer>
> >>>        <tokenizer class="solr.KeywordTokenizerFactory"/>
> >>>        <filter class="solr.LowerCaseFilterFactory" />
> >>>        <filter class="solr.TrimFilterFactory" />
> >>>        <filter class="solr.StopFilterFactory" ignoreCase="true"
> >>> words="stopwords.txt" enablePositionIncrements="true"/>
> >>>        <filter class="solr.SynonymFilterFactory"
> synonyms="synonyms.txt"
> >>> ignoreCase="true" expand="false" />
> >>>        <filter class="solr.RemoveDuplicatesTokenFilterFactory"/>
> >>>      </analyzer>
> >>>    </fieldType>
> >>>
> >>>    <field name="keyphrase" type="text_keyword" indexed="true"
> >>> stored="false" multiValued="true"/>
> >>>
> >>> With this query
> >>> q=smart%20mobile&qf=keyphrase&debugQuery=on&defType=dismax,
> >>> solr returns nothing. However, with quote on the search query q="smart
> >>> mobile"&qf=keyphrase&debugQuery=on&defType=dismax, the result is found.
> >>>
> >>> Is it a must to use quote for a single word token field?
> >>
> >> Yes, you must currently quote tokens if they contain whitespace -
> >> otherwise the query parser first breaks on whitespace before doing
> >> analysis on each part separately.
> >>
> >> Using dismax is an odd choice if you are only querying on keyphrase
> though.
> >> You might look at the field query parser - it is a basic single-field
> >> single-value parser with no operators (hence no need to escape any
> >> special characters).
> >>
> >> q={!field f=keyphrase}smart%20mobile
> >>
> >> or you can decompose it using param dereferencing (sometimes easier to
> >> construct)
> >>
> >> q={!field f=keyphrase v=$qq}&qq=smart%20mobile
> >>
> >> -Yonik
> >> http://www.lucidimagination.com
> >>
> >
> > --
> > Sent from my mobile device
> >
> > Chhorn Chamnap
> > http://chamnapchhorn.blogspot.com/
> >
>



-- 
Chhorn Chamnap
http://chamnapchhorn.blogspot.com/

Re: Must require quote with single word token query?

Posted by Yonik Seeley <yo...@lucidimagination.com>.
On Fri, Nov 19, 2010 at 9:41 PM, Chamnap Chhorn <ch...@gmail.com> wrote:
> Wow, i never know this syntax before. What's that called?

I dubbed it "local params" since it adds local info to a parameter
(think extra metadata, like XML attributes on an element).

http://wiki.apache.org/solr/LocalParams

It's used mostly to invoke different query parsers, but it's also used
to add extra metadata to faceting commands too (and is required for
stuff like multi-select faceting):

http://wiki.apache.org/solr/SimpleFacetParameters#Multi-Select_Faceting_and_LocalParams


-Yonik
http://www.lucidimagination.com



> On 11/19/10, Yonik Seeley <yo...@lucidimagination.com> wrote:
>> On Tue, Nov 16, 2010 at 10:28 PM, Chamnap Chhorn
>> <ch...@gmail.com> wrote:
>>> I have one question related to single word token with dismax query. In
>>> order
>>> to be found I need to add the quote around the search query all the time.
>>> This is quite hard for me to do since it is part of full text search.
>>>
>>> Here is my solr query and field type definition (Solr 1.4):
>>>    <fieldType name="text_keyword" class="solr.TextField"
>>> positionIncrementGap="100">
>>>      <analyzer>
>>>        <tokenizer class="solr.KeywordTokenizerFactory"/>
>>>        <filter class="solr.LowerCaseFilterFactory" />
>>>        <filter class="solr.TrimFilterFactory" />
>>>        <filter class="solr.StopFilterFactory" ignoreCase="true"
>>> words="stopwords.txt" enablePositionIncrements="true"/>
>>>        <filter class="solr.SynonymFilterFactory" synonyms="synonyms.txt"
>>> ignoreCase="true" expand="false" />
>>>        <filter class="solr.RemoveDuplicatesTokenFilterFactory"/>
>>>      </analyzer>
>>>    </fieldType>
>>>
>>>    <field name="keyphrase" type="text_keyword" indexed="true"
>>> stored="false" multiValued="true"/>
>>>
>>> With this query
>>> q=smart%20mobile&qf=keyphrase&debugQuery=on&defType=dismax,
>>> solr returns nothing. However, with quote on the search query q="smart
>>> mobile"&qf=keyphrase&debugQuery=on&defType=dismax, the result is found.
>>>
>>> Is it a must to use quote for a single word token field?
>>
>> Yes, you must currently quote tokens if they contain whitespace -
>> otherwise the query parser first breaks on whitespace before doing
>> analysis on each part separately.
>>
>> Using dismax is an odd choice if you are only querying on keyphrase though.
>> You might look at the field query parser - it is a basic single-field
>> single-value parser with no operators (hence no need to escape any
>> special characters).
>>
>> q={!field f=keyphrase}smart%20mobile
>>
>> or you can decompose it using param dereferencing (sometimes easier to
>> construct)
>>
>> q={!field f=keyphrase v=$qq}&qq=smart%20mobile
>>
>> -Yonik
>> http://www.lucidimagination.com
>>
>
> --
> Sent from my mobile device
>
> Chhorn Chamnap
> http://chamnapchhorn.blogspot.com/
>

Re: Must require quote with single word token query?

Posted by Chamnap Chhorn <ch...@gmail.com>.
Wow, i never know this syntax before. What's that called?

On 11/19/10, Yonik Seeley <yo...@lucidimagination.com> wrote:
> On Tue, Nov 16, 2010 at 10:28 PM, Chamnap Chhorn
> <ch...@gmail.com> wrote:
>> I have one question related to single word token with dismax query. In
>> order
>> to be found I need to add the quote around the search query all the time.
>> This is quite hard for me to do since it is part of full text search.
>>
>> Here is my solr query and field type definition (Solr 1.4):
>>    <fieldType name="text_keyword" class="solr.TextField"
>> positionIncrementGap="100">
>>      <analyzer>
>>        <tokenizer class="solr.KeywordTokenizerFactory"/>
>>        <filter class="solr.LowerCaseFilterFactory" />
>>        <filter class="solr.TrimFilterFactory" />
>>        <filter class="solr.StopFilterFactory" ignoreCase="true"
>> words="stopwords.txt" enablePositionIncrements="true"/>
>>        <filter class="solr.SynonymFilterFactory" synonyms="synonyms.txt"
>> ignoreCase="true" expand="false" />
>>        <filter class="solr.RemoveDuplicatesTokenFilterFactory"/>
>>      </analyzer>
>>    </fieldType>
>>
>>    <field name="keyphrase" type="text_keyword" indexed="true"
>> stored="false" multiValued="true"/>
>>
>> With this query
>> q=smart%20mobile&qf=keyphrase&debugQuery=on&defType=dismax,
>> solr returns nothing. However, with quote on the search query q="smart
>> mobile"&qf=keyphrase&debugQuery=on&defType=dismax, the result is found.
>>
>> Is it a must to use quote for a single word token field?
>
> Yes, you must currently quote tokens if they contain whitespace -
> otherwise the query parser first breaks on whitespace before doing
> analysis on each part separately.
>
> Using dismax is an odd choice if you are only querying on keyphrase though.
> You might look at the field query parser - it is a basic single-field
> single-value parser with no operators (hence no need to escape any
> special characters).
>
> q={!field f=keyphrase}smart%20mobile
>
> or you can decompose it using param dereferencing (sometimes easier to
> construct)
>
> q={!field f=keyphrase v=$qq}&qq=smart%20mobile
>
> -Yonik
> http://www.lucidimagination.com
>

-- 
Sent from my mobile device

Chhorn Chamnap
http://chamnapchhorn.blogspot.com/

Re: Must require quote with single word token query?

Posted by Yonik Seeley <yo...@lucidimagination.com>.
On Tue, Nov 16, 2010 at 10:28 PM, Chamnap Chhorn
<ch...@gmail.com> wrote:
> I have one question related to single word token with dismax query. In order
> to be found I need to add the quote around the search query all the time.
> This is quite hard for me to do since it is part of full text search.
>
> Here is my solr query and field type definition (Solr 1.4):
>    <fieldType name="text_keyword" class="solr.TextField"
> positionIncrementGap="100">
>      <analyzer>
>        <tokenizer class="solr.KeywordTokenizerFactory"/>
>        <filter class="solr.LowerCaseFilterFactory" />
>        <filter class="solr.TrimFilterFactory" />
>        <filter class="solr.StopFilterFactory" ignoreCase="true"
> words="stopwords.txt" enablePositionIncrements="true"/>
>        <filter class="solr.SynonymFilterFactory" synonyms="synonyms.txt"
> ignoreCase="true" expand="false" />
>        <filter class="solr.RemoveDuplicatesTokenFilterFactory"/>
>      </analyzer>
>    </fieldType>
>
>    <field name="keyphrase" type="text_keyword" indexed="true"
> stored="false" multiValued="true"/>
>
> With this query q=smart%20mobile&qf=keyphrase&debugQuery=on&defType=dismax,
> solr returns nothing. However, with quote on the search query q="smart
> mobile"&qf=keyphrase&debugQuery=on&defType=dismax, the result is found.
>
> Is it a must to use quote for a single word token field?

Yes, you must currently quote tokens if they contain whitespace -
otherwise the query parser first breaks on whitespace before doing
analysis on each part separately.

Using dismax is an odd choice if you are only querying on keyphrase though.
You might look at the field query parser - it is a basic single-field
single-value parser with no operators (hence no need to escape any
special characters).

q={!field f=keyphrase}smart%20mobile

or you can decompose it using param dereferencing (sometimes easier to
construct)

q={!field f=keyphrase v=$qq}&qq=smart%20mobile

-Yonik
http://www.lucidimagination.com

Re: Must require quote with single word token query?

Posted by Chamnap Chhorn <ch...@gmail.com>.
Well, this field is a keyphrase. I want to make it to case-insensitive
single token field. It matches only when the user types the same as data in
solr.

What's wrong with that? Does it can be done in another way?

On Thu, Nov 18, 2010 at 6:08 PM, Ahmet Arslan <io...@yahoo.com> wrote:

> This happening because query parser pre-tokenizes your query using whites
> paces. It is tokenized before it reaches your query analyzer.
> And you are using KeywordTokenizer in your field definition.
>
> Is there a special reason for you to use KeywordTokenizer ?
>
>
> --- On Thu, 11/18/10, Chamnap Chhorn <ch...@gmail.com> wrote:
>
> > From: Chamnap Chhorn <ch...@gmail.com>
> > Subject: Re: Must require quote with single word token query?
> > To: solr-user@lucene.apache.org
> > Date: Thursday, November 18, 2010, 5:19 AM
> > Thanks for your reply. Here is some
> > other details:
> >
> > 1. Keyphrase field definition:
> >    <field name="keyphrase"
> > type="text_keyword" indexed="true" stored="false"
> > multiValued="true"/>
> >
> > 2. I'm using solr 1.4.
> >
> > 3. My dismax definition is the original configuration after
> > install solr:
> >   <requestHandler name="dismax"
> > class="solr.SearchHandler" >
> >     <lst name="defaults">
> >      <str
> > name="defType">dismax</str>
> >      <str
> > name="echoParams">explicit</str>
> >      <float
> > name="tie">0.01</float>
> >      <str name="qf">
> >         text^0.5 features^1.0 name^1.2
> > sku^1.5 id^10.0 manu^1.1 cat^1.4
> >      </str>
> >      <str name="pf">
> >         text^0.2 features^1.1 name^1.5
> > manu^1.4 manu_exact^1.9
> >      </str>
> >      <str name="bf">
> >         popularity^0.5
> > recip(price,1,1000,1000)^0.3
> >      </str>
> >      <str name="fl">
> >         id,name,price,score
> >      </str>
> >      <str name="mm">
> >         2<-1 5<-2
> > 6<90%
> >      </str>
> >      <int
> > name="ps">100</int>
> >      <str
> > name="q.alt">*:*</str>
> >      <!-- example highlighter
> > config, enable per-query with hl=true -->
> >      <str name="hl.fl">text
> > features name</str>
> >      <!-- for this field, we want no
> > fragmenting, just highlighting -->
> >      <str
> > name="f.name.hl.fragsize">0</str>
> >      <!-- instructs Solr to return
> > the field itself if no query terms are
> >           found -->
> >      <str
> > name="f.name.hl.alternateField">name</str>
> >      <str
> > name="f.text.hl.fragmenter">regex</str> <!--
> > defined below -->
> >     </lst>
> >   </requestHandler>
> >
> > 4. Here is the result returned back of the original query:
> > smart mobile.
> >
> > <?xml version="1.0" encoding="UTF-8"?>
> >
> > <response>
> >
> > <lst name="responseHeader">
> >  <int name="status">0</int>
> >
> >  <int name="QTime">1</int>
> >  <lst name="params">
> >
> >   <str name="debugQuery">on</str>
> >   <str name="fl">uuid,name,fap</str>
> >
> >   <str name="indent">true</str>
> >   <str name="q">smart mobile</str>
> >
> >   <str name="qf">keyphrase</str>
> >   <str name="defType">dismax</str>
> >
> >  </lst>
> > </lst>
> > <result name="response" numFound="0" start="0"/>
> >
> > <lst name="debug">
> >
> >  <str name="rawquerystring">smart mobile</str>
> >
> >  <str name="querystring">smart mobile</str>
> >  <str
> > name="parsedquery">+((DisjunctionMaxQuery((keyphrase:smart))
> > DisjunctionMaxQuery((keyphrase:mobile)))~2) ()</str>
> >
> >  <str
> > name="parsedquery_toString">+(((keyphrase:smart)
> > (keyphrase:mobile))~2) ()</str>
> >
> >  <lst name="explain"/>
> >  <str name="QParser">DisMaxQParser</str>
> >
> >  <null name="altquerystring"/>
> >  <null name="boostfuncs"/>
> >
> >  <lst name="timing">
> >   <double name="time">1.0</double>
> >
> >   <lst name="prepare">
> >     <double
> > name="time">1.0</double>
> >
> >     <lst
> > name="org.apache.solr.handler.component.QueryComponent">
> >      <double
> > name="time">1.0</double>
> >
> >     </lst>
> >     <lst
> > name="org.apache.solr.handler.component.FacetComponent">
> >
> >      <double
> > name="time">0.0</double>
> >     </lst>
> >
> >     <lst
> > name="org.apache.solr.handler.component.MoreLikeThisComponent">
> >      <double
> > name="time">0.0</double>
> >
> >     </lst>
> >     <lst
> > name="org.apache.solr.handler.component.HighlightComponent">
> >
> >      <double
> > name="time">0.0</double>
> >     </lst>
> >
> >     <lst
> > name="org.apache.solr.handler.component.StatsComponent">
> >      <double
> > name="time">0.0</double>
> >
> >     </lst>
> >     <lst
> > name="org.apache.solr.handler.component.DebugComponent">
> >
> >      <double
> > name="time">0.0</double>
> >
> >     </lst>
> >
> >   </lst>
> >   <lst name="process">
> >     <double
> > name="time">0.0</double>
> >
> >     <lst
> > name="org.apache.solr.handler.component.QueryComponent">
> >      <double
> > name="time">0.0</double>
> >
> >     </lst>
> >     <lst
> > name="org.apache.solr.handler.component.FacetComponent">
> >
> >      <double
> > name="time">0.0</double>
> >     </lst>
> >
> >     <lst
> > name="org.apache.solr.handler.component.MoreLikeThisComponent">
> >      <double
> > name="time">0.0</double>
> >
> >     </lst>
> >     <lst
> > name="org.apache.solr.handler.component.HighlightComponent">
> >
> >      <double
> > name="time">0.0</double>
> >
> >     </lst>
> >
> >     <lst
> > name="org.apache.solr.handler.component.StatsComponent">
> >      <double
> > name="time">0.0</double>
> >
> >     </lst>
> >     <lst
> > name="org.apache.solr.handler.component.DebugComponent">
> >
> >      <double
> > name="time">0.0</double>
> >     </lst>
> >
> >   </lst>
> >
> >  </lst>
> > </lst>
> > </response>
> >
> > 5. Here is parsed query with "smart mobile" (with quotes)
> > which returns the
> > result:
> >
> > <lst name="debug">
> >  <str name="rawquerystring">"smart
> > mobile"</str>
> >
> >  <str name="querystring">"smart mobile"</str>
> >
> >
> >  <str
> > name="parsedquery">+DisjunctionMaxQuery((keyphrase:smart
> > mobile)) ()</str>
> >
> >  <str name="parsedquery_toString">+(keyphrase:smart
> > mobile) ()</str>
> >
> >  <lst name="explain">
> >   <str
> > name="D297A64B-D4BA-4445-B63E-726E5A4F758D">
> >
> > 4.503682 = (MATCH) sum of:
> >   4.503682 = (MATCH) fieldWeight(keyphrase:smart
> > mobile in 13092), product of:
> >     1.0 = tf(termFreq(keyphrase:smart mobile)=1)
> >     10.29413 = idf(docFreq=1, maxDocs=21748)
> >     0.4375 = fieldNorm(field=keyphrase,
> > doc=13092)
> >
> > </str>
> >  </lst>
> >
> > 6. Here, I tried to use automatic phrase query (pf
> > parameter): doesn't
> > return any results.
> >
> http://localhost:8081/solr/select?q=smart%20mobile&qf=keyphrase&pf=keyphrase&debugQuery=on&defType=dismax
> >
> >  <str name="rawquerystring">smart mobile</str>
> >
> >  <str name="querystring">smart mobile</str>
> >  <str
> > name="parsedquery">+((DisjunctionMaxQuery((keyphrase:smart))
> > DisjunctionMaxQuery((keyphrase:mobile)))~2)
> > DisjunctionMaxQuery((keyphrase:smart mobile))</str>
> >
> >  <str
> > name="parsedquery_toString">+(((keyphrase:smart)
> > (keyphrase:mobile))~2) (keyphrase:smart
> > mobile)</str>
> >
> >  <lst name="explain"/>
> >
> >  <str name="QParser">DisMaxQParser</str>
> >
> >  <null name="altquerystring"/>
> >  <null name="boostfuncs"/>
> >
> > Thanks
> > Chamnap
> >
> > On Wed, Nov 17, 2010 at 8:10 PM, Erick Erickson <erickerickson@gmail.com
> >wrote:
> >
> > > Try qt=dismax or deftype=dismax, I was also getting 0
> > results with
> > > defType on 1.4.1. I'll see what's up with that...
> > >
> > > But if that doesn't work...
> > >
> > > May we see your dismax definition too? You shouldn't
> > need the
> > > quotes, so something's wrong somewhere....
> > >
> > > What version of Solr are you using?
> > >
> > > Also, please post the results of running your original
> > query
> > > with &debugQuery=on
> > >
> > > Best
> > > Erick
> > >
> > > On Tue, Nov 16, 2010 at 10:28 PM, Chamnap Chhorn
> > <chamnapchhorn@gmail.com
> > > >wrote:
> > >
> > > > I have one question related to single word token
> > with dismax query. In
> > > > order
> > > > to be found I need to add the quote around the
> > search query all the time.
> > > > This is quite hard for me to do since it is part
> > of full text search.
> > > >
> > > > Here is my solr query and field type definition
> > (Solr 1.4):
> > > >    <fieldType name="text_keyword"
> > class="solr.TextField"
> > > > positionIncrementGap="100">
> > > >      <analyzer>
> > > >        <tokenizer
> > class="solr.KeywordTokenizerFactory"/>
> > > >        <filter
> > class="solr.LowerCaseFilterFactory" />
> > > >        <filter
> > class="solr.TrimFilterFactory" />
> > > >        <filter
> > class="solr.StopFilterFactory" ignoreCase="true"
> > > > words="stopwords.txt"
> > enablePositionIncrements="true"/>
> > > >        <filter
> > class="solr.SynonymFilterFactory" synonyms="synonyms.txt"
> > > > ignoreCase="true" expand="false" />
> > > >        <filter
> > class="solr.RemoveDuplicatesTokenFilterFactory"/>
> > > >      </analyzer>
> > > >    </fieldType>
> > > >
> > > >    <field name="keyphrase"
> > type="text_keyword" indexed="true"
> > > > stored="false" multiValued="true"/>
> > > >
> > > > With this query
> > >
> > q=smart%20mobile&qf=keyphrase&debugQuery=on&defType=dismax,
> > > > solr returns nothing. However, with quote on the
> > search query q="smart
> > > >
> > mobile"&qf=keyphrase&debugQuery=on&defType=dismax,
> > the result is found.
> > > >
> > > > Is it a must to use quote for a single word token
> > field?
> > > >
> > > > --
> > > > Chhorn Chamnap
> > > > http://chamnapchhorn.blogspot.com/
> > > >
> > >
> >
> >
> >
> > --
> > Chhorn Chamnap
> > http://chamnapchhorn.blogspot.com/
> >
>
>
>
>


-- 
Chhorn Chamnap
http://chamnapchhorn.blogspot.com/

Re: Must require quote with single word token query?

Posted by Ahmet Arslan <io...@yahoo.com>.
This happening because query parser pre-tokenizes your query using whites paces. It is tokenized before it reaches your query analyzer.
And you are using KeywordTokenizer in your field definition.

Is there a special reason for you to use KeywordTokenizer ?


--- On Thu, 11/18/10, Chamnap Chhorn <ch...@gmail.com> wrote:

> From: Chamnap Chhorn <ch...@gmail.com>
> Subject: Re: Must require quote with single word token query?
> To: solr-user@lucene.apache.org
> Date: Thursday, November 18, 2010, 5:19 AM
> Thanks for your reply. Here is some
> other details:
> 
> 1. Keyphrase field definition:
>    <field name="keyphrase"
> type="text_keyword" indexed="true" stored="false"
> multiValued="true"/>
> 
> 2. I'm using solr 1.4.
> 
> 3. My dismax definition is the original configuration after
> install solr:
>   <requestHandler name="dismax"
> class="solr.SearchHandler" >
>     <lst name="defaults">
>      <str
> name="defType">dismax</str>
>      <str
> name="echoParams">explicit</str>
>      <float
> name="tie">0.01</float>
>      <str name="qf">
>         text^0.5 features^1.0 name^1.2
> sku^1.5 id^10.0 manu^1.1 cat^1.4
>      </str>
>      <str name="pf">
>         text^0.2 features^1.1 name^1.5
> manu^1.4 manu_exact^1.9
>      </str>
>      <str name="bf">
>         popularity^0.5
> recip(price,1,1000,1000)^0.3
>      </str>
>      <str name="fl">
>         id,name,price,score
>      </str>
>      <str name="mm">
>         2&lt;-1 5&lt;-2
> 6&lt;90%
>      </str>
>      <int
> name="ps">100</int>
>      <str
> name="q.alt">*:*</str>
>      <!-- example highlighter
> config, enable per-query with hl=true -->
>      <str name="hl.fl">text
> features name</str>
>      <!-- for this field, we want no
> fragmenting, just highlighting -->
>      <str
> name="f.name.hl.fragsize">0</str>
>      <!-- instructs Solr to return
> the field itself if no query terms are
>           found -->
>      <str
> name="f.name.hl.alternateField">name</str>
>      <str
> name="f.text.hl.fragmenter">regex</str> <!--
> defined below -->
>     </lst>
>   </requestHandler>
> 
> 4. Here is the result returned back of the original query:
> smart mobile.
> 
> <?xml version="1.0" encoding="UTF-8"?>
> 
> <response>
> 
> <lst name="responseHeader">
>  <int name="status">0</int>
> 
>  <int name="QTime">1</int>
>  <lst name="params">
> 
>   <str name="debugQuery">on</str>
>   <str name="fl">uuid,name,fap</str>
> 
>   <str name="indent">true</str>
>   <str name="q">smart mobile</str>
> 
>   <str name="qf">keyphrase</str>
>   <str name="defType">dismax</str>
> 
>  </lst>
> </lst>
> <result name="response" numFound="0" start="0"/>
> 
> <lst name="debug">
> 
>  <str name="rawquerystring">smart mobile</str>
> 
>  <str name="querystring">smart mobile</str>
>  <str
> name="parsedquery">+((DisjunctionMaxQuery((keyphrase:smart))
> DisjunctionMaxQuery((keyphrase:mobile)))~2) ()</str>
> 
>  <str
> name="parsedquery_toString">+(((keyphrase:smart)
> (keyphrase:mobile))~2) ()</str>
> 
>  <lst name="explain"/>
>  <str name="QParser">DisMaxQParser</str>
> 
>  <null name="altquerystring"/>
>  <null name="boostfuncs"/>
> 
>  <lst name="timing">
>   <double name="time">1.0</double>
> 
>   <lst name="prepare">
>     <double
> name="time">1.0</double>
> 
>     <lst
> name="org.apache.solr.handler.component.QueryComponent">
>      <double
> name="time">1.0</double>
> 
>     </lst>
>     <lst
> name="org.apache.solr.handler.component.FacetComponent">
> 
>      <double
> name="time">0.0</double>
>     </lst>
> 
>     <lst
> name="org.apache.solr.handler.component.MoreLikeThisComponent">
>      <double
> name="time">0.0</double>
> 
>     </lst>
>     <lst
> name="org.apache.solr.handler.component.HighlightComponent">
> 
>      <double
> name="time">0.0</double>
>     </lst>
> 
>     <lst
> name="org.apache.solr.handler.component.StatsComponent">
>      <double
> name="time">0.0</double>
> 
>     </lst>
>     <lst
> name="org.apache.solr.handler.component.DebugComponent">
> 
>      <double
> name="time">0.0</double>
> 
>     </lst>
> 
>   </lst>
>   <lst name="process">
>     <double
> name="time">0.0</double>
> 
>     <lst
> name="org.apache.solr.handler.component.QueryComponent">
>      <double
> name="time">0.0</double>
> 
>     </lst>
>     <lst
> name="org.apache.solr.handler.component.FacetComponent">
> 
>      <double
> name="time">0.0</double>
>     </lst>
> 
>     <lst
> name="org.apache.solr.handler.component.MoreLikeThisComponent">
>      <double
> name="time">0.0</double>
> 
>     </lst>
>     <lst
> name="org.apache.solr.handler.component.HighlightComponent">
> 
>      <double
> name="time">0.0</double>
> 
>     </lst>
> 
>     <lst
> name="org.apache.solr.handler.component.StatsComponent">
>      <double
> name="time">0.0</double>
> 
>     </lst>
>     <lst
> name="org.apache.solr.handler.component.DebugComponent">
> 
>      <double
> name="time">0.0</double>
>     </lst>
> 
>   </lst>
> 
>  </lst>
> </lst>
> </response>
> 
> 5. Here is parsed query with "smart mobile" (with quotes)
> which returns the
> result:
> 
> <lst name="debug">
>  <str name="rawquerystring">"smart
> mobile"</str>
> 
>  <str name="querystring">"smart mobile"</str>
> 
> 
>  <str
> name="parsedquery">+DisjunctionMaxQuery((keyphrase:smart
> mobile)) ()</str>
> 
>  <str name="parsedquery_toString">+(keyphrase:smart
> mobile) ()</str>
> 
>  <lst name="explain">
>   <str
> name="D297A64B-D4BA-4445-B63E-726E5A4F758D">
> 
> 4.503682 = (MATCH) sum of:
>   4.503682 = (MATCH) fieldWeight(keyphrase:smart
> mobile in 13092), product of:
>     1.0 = tf(termFreq(keyphrase:smart mobile)=1)
>     10.29413 = idf(docFreq=1, maxDocs=21748)
>     0.4375 = fieldNorm(field=keyphrase,
> doc=13092)
> 
> </str>
>  </lst>
> 
> 6. Here, I tried to use automatic phrase query (pf
> parameter): doesn't
> return any results.
> http://localhost:8081/solr/select?q=smart%20mobile&qf=keyphrase&pf=keyphrase&debugQuery=on&defType=dismax
> 
>  <str name="rawquerystring">smart mobile</str>
> 
>  <str name="querystring">smart mobile</str>
>  <str
> name="parsedquery">+((DisjunctionMaxQuery((keyphrase:smart))
> DisjunctionMaxQuery((keyphrase:mobile)))~2)
> DisjunctionMaxQuery((keyphrase:smart mobile))</str>
> 
>  <str
> name="parsedquery_toString">+(((keyphrase:smart)
> (keyphrase:mobile))~2) (keyphrase:smart
> mobile)</str>
> 
>  <lst name="explain"/>
> 
>  <str name="QParser">DisMaxQParser</str>
> 
>  <null name="altquerystring"/>
>  <null name="boostfuncs"/>
> 
> Thanks
> Chamnap
> 
> On Wed, Nov 17, 2010 at 8:10 PM, Erick Erickson <er...@gmail.com>wrote:
> 
> > Try qt=dismax or deftype=dismax, I was also getting 0
> results with
> > defType on 1.4.1. I'll see what's up with that...
> >
> > But if that doesn't work...
> >
> > May we see your dismax definition too? You shouldn't
> need the
> > quotes, so something's wrong somewhere....
> >
> > What version of Solr are you using?
> >
> > Also, please post the results of running your original
> query
> > with &debugQuery=on
> >
> > Best
> > Erick
> >
> > On Tue, Nov 16, 2010 at 10:28 PM, Chamnap Chhorn
> <chamnapchhorn@gmail.com
> > >wrote:
> >
> > > I have one question related to single word token
> with dismax query. In
> > > order
> > > to be found I need to add the quote around the
> search query all the time.
> > > This is quite hard for me to do since it is part
> of full text search.
> > >
> > > Here is my solr query and field type definition
> (Solr 1.4):
> > >    <fieldType name="text_keyword"
> class="solr.TextField"
> > > positionIncrementGap="100">
> > >      <analyzer>
> > >        <tokenizer
> class="solr.KeywordTokenizerFactory"/>
> > >        <filter
> class="solr.LowerCaseFilterFactory" />
> > >        <filter
> class="solr.TrimFilterFactory" />
> > >        <filter
> class="solr.StopFilterFactory" ignoreCase="true"
> > > words="stopwords.txt"
> enablePositionIncrements="true"/>
> > >        <filter
> class="solr.SynonymFilterFactory" synonyms="synonyms.txt"
> > > ignoreCase="true" expand="false" />
> > >        <filter
> class="solr.RemoveDuplicatesTokenFilterFactory"/>
> > >      </analyzer>
> > >    </fieldType>
> > >
> > >    <field name="keyphrase"
> type="text_keyword" indexed="true"
> > > stored="false" multiValued="true"/>
> > >
> > > With this query
> >
> q=smart%20mobile&qf=keyphrase&debugQuery=on&defType=dismax,
> > > solr returns nothing. However, with quote on the
> search query q="smart
> > >
> mobile"&qf=keyphrase&debugQuery=on&defType=dismax,
> the result is found.
> > >
> > > Is it a must to use quote for a single word token
> field?
> > >
> > > --
> > > Chhorn Chamnap
> > > http://chamnapchhorn.blogspot.com/
> > >
> >
> 
> 
> 
> -- 
> Chhorn Chamnap
> http://chamnapchhorn.blogspot.com/
> 


      

Re: Must require quote with single word token query?

Posted by Chamnap Chhorn <ch...@gmail.com>.
Thanks for your reply. Here is some other details:

1. Keyphrase field definition:
   <field name="keyphrase" type="text_keyword" indexed="true" stored="false"
multiValued="true"/>

2. I'm using solr 1.4.

3. My dismax definition is the original configuration after install solr:
  <requestHandler name="dismax" class="solr.SearchHandler" >
    <lst name="defaults">
     <str name="defType">dismax</str>
     <str name="echoParams">explicit</str>
     <float name="tie">0.01</float>
     <str name="qf">
        text^0.5 features^1.0 name^1.2 sku^1.5 id^10.0 manu^1.1 cat^1.4
     </str>
     <str name="pf">
        text^0.2 features^1.1 name^1.5 manu^1.4 manu_exact^1.9
     </str>
     <str name="bf">
        popularity^0.5 recip(price,1,1000,1000)^0.3
     </str>
     <str name="fl">
        id,name,price,score
     </str>
     <str name="mm">
        2&lt;-1 5&lt;-2 6&lt;90%
     </str>
     <int name="ps">100</int>
     <str name="q.alt">*:*</str>
     <!-- example highlighter config, enable per-query with hl=true -->
     <str name="hl.fl">text features name</str>
     <!-- for this field, we want no fragmenting, just highlighting -->
     <str name="f.name.hl.fragsize">0</str>
     <!-- instructs Solr to return the field itself if no query terms are
          found -->
     <str name="f.name.hl.alternateField">name</str>
     <str name="f.text.hl.fragmenter">regex</str> <!-- defined below -->
    </lst>
  </requestHandler>

4. Here is the result returned back of the original query: smart mobile.

<?xml version="1.0" encoding="UTF-8"?>

<response>

<lst name="responseHeader">
 <int name="status">0</int>

 <int name="QTime">1</int>
 <lst name="params">

  <str name="debugQuery">on</str>
  <str name="fl">uuid,name,fap</str>

  <str name="indent">true</str>
  <str name="q">smart mobile</str>

  <str name="qf">keyphrase</str>
  <str name="defType">dismax</str>

 </lst>
</lst>
<result name="response" numFound="0" start="0"/>

<lst name="debug">

 <str name="rawquerystring">smart mobile</str>

 <str name="querystring">smart mobile</str>
 <str name="parsedquery">+((DisjunctionMaxQuery((keyphrase:smart))
DisjunctionMaxQuery((keyphrase:mobile)))~2) ()</str>

 <str name="parsedquery_toString">+(((keyphrase:smart)
(keyphrase:mobile))~2) ()</str>

 <lst name="explain"/>
 <str name="QParser">DisMaxQParser</str>

 <null name="altquerystring"/>
 <null name="boostfuncs"/>

 <lst name="timing">
  <double name="time">1.0</double>

  <lst name="prepare">
	<double name="time">1.0</double>

	<lst name="org.apache.solr.handler.component.QueryComponent">
	 <double name="time">1.0</double>

	</lst>
	<lst name="org.apache.solr.handler.component.FacetComponent">

	 <double name="time">0.0</double>
	</lst>

	<lst name="org.apache.solr.handler.component.MoreLikeThisComponent">
	 <double name="time">0.0</double>

	</lst>
	<lst name="org.apache.solr.handler.component.HighlightComponent">

	 <double name="time">0.0</double>
	</lst>

	<lst name="org.apache.solr.handler.component.StatsComponent">
	 <double name="time">0.0</double>

	</lst>
	<lst name="org.apache.solr.handler.component.DebugComponent">

	 <double name="time">0.0</double>

	</lst>

  </lst>
  <lst name="process">
	<double name="time">0.0</double>

	<lst name="org.apache.solr.handler.component.QueryComponent">
	 <double name="time">0.0</double>

	</lst>
	<lst name="org.apache.solr.handler.component.FacetComponent">

	 <double name="time">0.0</double>
	</lst>

	<lst name="org.apache.solr.handler.component.MoreLikeThisComponent">
	 <double name="time">0.0</double>

	</lst>
	<lst name="org.apache.solr.handler.component.HighlightComponent">

	 <double name="time">0.0</double>

	</lst>

	<lst name="org.apache.solr.handler.component.StatsComponent">
	 <double name="time">0.0</double>

	</lst>
	<lst name="org.apache.solr.handler.component.DebugComponent">

	 <double name="time">0.0</double>
	</lst>

  </lst>

 </lst>
</lst>
</response>

5. Here is parsed query with "smart mobile" (with quotes) which returns the
result:

<lst name="debug">
 <str name="rawquerystring">"smart mobile"</str>

 <str name="querystring">"smart mobile"</str>


 <str name="parsedquery">+DisjunctionMaxQuery((keyphrase:smart mobile)) ()</str>

 <str name="parsedquery_toString">+(keyphrase:smart mobile) ()</str>

 <lst name="explain">
  <str name="D297A64B-D4BA-4445-B63E-726E5A4F758D">

4.503682 = (MATCH) sum of:
  4.503682 = (MATCH) fieldWeight(keyphrase:smart mobile in 13092), product of:
    1.0 = tf(termFreq(keyphrase:smart mobile)=1)
    10.29413 = idf(docFreq=1, maxDocs=21748)
    0.4375 = fieldNorm(field=keyphrase, doc=13092)

</str>
 </lst>

6. Here, I tried to use automatic phrase query (pf parameter): doesn't
return any results.
http://localhost:8081/solr/select?q=smart%20mobile&qf=keyphrase&pf=keyphrase&debugQuery=on&defType=dismax

 <str name="rawquerystring">smart mobile</str>

 <str name="querystring">smart mobile</str>
 <str name="parsedquery">+((DisjunctionMaxQuery((keyphrase:smart))
DisjunctionMaxQuery((keyphrase:mobile)))~2)
DisjunctionMaxQuery((keyphrase:smart mobile))</str>

 <str name="parsedquery_toString">+(((keyphrase:smart)
(keyphrase:mobile))~2) (keyphrase:smart mobile)</str>

 <lst name="explain"/>

 <str name="QParser">DisMaxQParser</str>

 <null name="altquerystring"/>
 <null name="boostfuncs"/>

Thanks
Chamnap

On Wed, Nov 17, 2010 at 8:10 PM, Erick Erickson <er...@gmail.com>wrote:

> Try qt=dismax or deftype=dismax, I was also getting 0 results with
> defType on 1.4.1. I'll see what's up with that...
>
> But if that doesn't work...
>
> May we see your dismax definition too? You shouldn't need the
> quotes, so something's wrong somewhere....
>
> What version of Solr are you using?
>
> Also, please post the results of running your original query
> with &debugQuery=on
>
> Best
> Erick
>
> On Tue, Nov 16, 2010 at 10:28 PM, Chamnap Chhorn <chamnapchhorn@gmail.com
> >wrote:
>
> > I have one question related to single word token with dismax query. In
> > order
> > to be found I need to add the quote around the search query all the time.
> > This is quite hard for me to do since it is part of full text search.
> >
> > Here is my solr query and field type definition (Solr 1.4):
> >    <fieldType name="text_keyword" class="solr.TextField"
> > positionIncrementGap="100">
> >      <analyzer>
> >        <tokenizer class="solr.KeywordTokenizerFactory"/>
> >        <filter class="solr.LowerCaseFilterFactory" />
> >        <filter class="solr.TrimFilterFactory" />
> >        <filter class="solr.StopFilterFactory" ignoreCase="true"
> > words="stopwords.txt" enablePositionIncrements="true"/>
> >        <filter class="solr.SynonymFilterFactory" synonyms="synonyms.txt"
> > ignoreCase="true" expand="false" />
> >        <filter class="solr.RemoveDuplicatesTokenFilterFactory"/>
> >      </analyzer>
> >    </fieldType>
> >
> >    <field name="keyphrase" type="text_keyword" indexed="true"
> > stored="false" multiValued="true"/>
> >
> > With this query
> q=smart%20mobile&qf=keyphrase&debugQuery=on&defType=dismax,
> > solr returns nothing. However, with quote on the search query q="smart
> > mobile"&qf=keyphrase&debugQuery=on&defType=dismax, the result is found.
> >
> > Is it a must to use quote for a single word token field?
> >
> > --
> > Chhorn Chamnap
> > http://chamnapchhorn.blogspot.com/
> >
>



-- 
Chhorn Chamnap
http://chamnapchhorn.blogspot.com/

Re: Must require quote with single word token query?

Posted by Erick Erickson <er...@gmail.com>.
Try qt=dismax or deftype=dismax, I was also getting 0 results with
defType on 1.4.1. I'll see what's up with that...

But if that doesn't work...

May we see your dismax definition too? You shouldn't need the
quotes, so something's wrong somewhere....

What version of Solr are you using?

Also, please post the results of running your original query
with &debugQuery=on

Best
Erick

On Tue, Nov 16, 2010 at 10:28 PM, Chamnap Chhorn <ch...@gmail.com>wrote:

> I have one question related to single word token with dismax query. In
> order
> to be found I need to add the quote around the search query all the time.
> This is quite hard for me to do since it is part of full text search.
>
> Here is my solr query and field type definition (Solr 1.4):
>    <fieldType name="text_keyword" class="solr.TextField"
> positionIncrementGap="100">
>      <analyzer>
>        <tokenizer class="solr.KeywordTokenizerFactory"/>
>        <filter class="solr.LowerCaseFilterFactory" />
>        <filter class="solr.TrimFilterFactory" />
>        <filter class="solr.StopFilterFactory" ignoreCase="true"
> words="stopwords.txt" enablePositionIncrements="true"/>
>        <filter class="solr.SynonymFilterFactory" synonyms="synonyms.txt"
> ignoreCase="true" expand="false" />
>        <filter class="solr.RemoveDuplicatesTokenFilterFactory"/>
>      </analyzer>
>    </fieldType>
>
>    <field name="keyphrase" type="text_keyword" indexed="true"
> stored="false" multiValued="true"/>
>
> With this query q=smart%20mobile&qf=keyphrase&debugQuery=on&defType=dismax,
> solr returns nothing. However, with quote on the search query q="smart
> mobile"&qf=keyphrase&debugQuery=on&defType=dismax, the result is found.
>
> Is it a must to use quote for a single word token field?
>
> --
> Chhorn Chamnap
> http://chamnapchhorn.blogspot.com/
>