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 Vladimir Sutskever <Vl...@jpmorgan.com> on 2010/06/15 23:56:36 UTC

Solr / Solrj Wildcard Phrase Searches

Performing wild card phrase searches can be tricky. Spend some time figuring this one out.


1. To perform a wildcard search on a phrase, it is very important to escape the SPACE, so that SOLR treats it as a single phrase.
Ex: Citibank NA => Citibank\ NA


You can use org.apache.solr.client.solrj.util.ClientUtils (part of solrj library) to perform the escapes


--------------
Example 
--------------
So that a search for: CITIBANK\ N*  

Should produce results: 
CITIBANK NA
CITIBANK NATIONAL
CITIBANK N


2. Also make sure your field (I named it "client_name_starts") is of fieldType that is maintained as a single Token during indexing. 

--------------
Example
--------------


<!-- lowercases the entire field value, keeping it as a single token.  -->
   <fieldType name="lowercase" class="solr.TextField" positionIncrementGap="100">
     <analyzer>
       <tokenizer class="solr.KeywordTokenizerFactory"/>
       <filter class="solr.LowerCaseFilterFactory" />
    </analyzer>
 </fieldType>


<field name="client_name_starts" type="lowercase" indexed="true" stored="true"  />



3. Make sure to Lower Case/Upper Case (depending on your setup) the search user input string, before sending it to SOLR - since wildcards are NOT analyzed - and send "AS IS"


Good Luck


Kind regards,

Vladimir Sutskever
Investment Bank - Technology
JPMorgan Chase, Inc.
Tel: (212) 552.5097






This email is confidential and subject to important disclaimers and
conditions including on offers for the purchase or sale of
securities, accuracy and completeness of information, viruses,
confidentiality, legal privilege, and legal entity disclaimers,
available at http://www.jpmorgan.com/pages/disclosures/email.  

Re: Solr / Solrj Wildcard Phrase Searches

Posted by Chris Hostetter <ho...@fucit.org>.
: Subject: Solr / Solrj Wildcard Phrase Searches
: References: <AA...@mail.gmail.com>
: In-Reply-To: <AA...@mail.gmail.com>

http://people.apache.org/~hossman/#threadhijack
Thread Hijacking on Mailing Lists

When starting a new discussion on a mailing list, please do not reply to 
an existing message, instead start a fresh email.  Even if you change the 
subject line of your email, other mail headers still track which thread 
you replied to and your question is "hidden" in that thread and gets less 
attention.   It makes following discussions in the mailing list archives 
particularly difficult.
See Also:  http://en.wikipedia.org/wiki/User:DonDiego/Thread_hijacking




-Hoss