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 [chamnapchh...@gmail.com] Sent: Wednesday, November 24, 2010 4:43 AM To: yo...@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 <chamnapchh...@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 > >> <chamnapchh...@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/