2012-09-04 19 views
5

यदि मेरे पास क्रिस मुएनच के साथ एक रिकॉर्ड है, तो मैं म्यू या Chr से मिलान करने में सक्षम होना चाहता हूं। मैं इसे एक सोलर क्वेरी के साथ कैसे कर सकता हूं। वर्तमान में मैं निम्न कार्य करें:सोलर वाइल्डकार्ड खोज

$results = $solr->search('"'.Apache_Solr_Service::escape($_GET['textsearch']).'"~100', 0, 100, array('fq' => 'type:datacollection')); 

यह Mue या Chr से मेल नहीं खाता है, लेकिन यह Muench से मेल खाता है

स्कीमा:

<?xml version="1.0" encoding="UTF-8" ?> 
<schema name="rocdocs" version="1.4"> 
    <types> 
    <!-- The StrField type is not analyzed, but indexed/stored verbatim. --> 
    <fieldType name="string" class="solr.StrField" sortMissingLast="true" omitNorms="true"/> 
    <fieldType name="int" class="solr.TrieIntField" precisionStep="0" omitNorms="true" positionIncrementGap="0"/> 
    <fieldType name="text_general" class="solr.TextField" positionIncrementGap="100"> 
     <analyzer type="index"> 
     <tokenizer class="solr.StandardTokenizerFactory"/> 
     <filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt" enablePositionIncrements="true" /> 
     <!-- in this example, we will only use synonyms at query time 
     <filter class="solr.SynonymFilterFactory" synonyms="index_synonyms.txt" ignoreCase="true" expand="false"/> 
     --> 
     <filter class="solr.LowerCaseFilterFactory"/> 
     </analyzer> 
     <analyzer type="query"> 
     <tokenizer class="solr.StandardTokenizerFactory"/> 
     <filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt" enablePositionIncrements="true" /> 
     <filter class="solr.SynonymFilterFactory" synonyms="synonyms.txt" ignoreCase="true" expand="true"/> 
     <filter class="solr.LowerCaseFilterFactory"/> 
     </analyzer> 
    </fieldType> 
</types> 


<fields> 
    <field name="type" type="string" indexed="true" stored="true" required="true" /> 
    <field name="mongo_id" type="string" indexed="true" stored="true" required="true" /> 
    <field name="nid" type="int" indexed="true" stored="true" required="true" /> 
    <field name="keywords" type="text_general" indexed="true" stored="false" /> 
</fields> 

<!-- Field to use to determine and enforce document uniqueness. 
     Unless this field is marked with required="false", it will be a required field 
    --> 
<uniqueKey>mongo_id</uniqueKey> 

<!-- field for the QueryParser to use when an explicit fieldname is absent --> 
<defaultSearchField>keywords</defaultSearchField> 
<!-- SolrQueryParser configuration: defaultOperator="AND|OR" --> 
<solrQueryParser defaultOperator="OR"/> 
</schema> 
+0

अतिरिक्त टिप्स के साथ संबंधित SO प्रश्न, यहां: http://stackoverflow.com/questions/1974394/apache-solr-search-part-of-the-word/1976045#1976045 –

उत्तर

7

आप या तो wildcard queries उदा उपयोग करने की आवश्यकता सीआर * या म्यू * जो मैच होगा।
यह या तो क्लाइंट या तो इस प्रारूप में क्वेरी दर्ज करेगा या इसे एप्लिकेशन में संशोधित करेगा।
अन्यथा, आप solr.EdgeNGramFilterFactory का उपयोग कर टोकन जेनरेट कर सकते हैं और यह रिकॉर्ड से मेल खाता है। जैसे क्रिस ch, chr, chri, chris उत्पन्न करेगा और इसलिए इन सभी संयोजनों से मेल खाएगा।

+0

मैंने कोशिश करने की कोशिश की: $ results = $ solr-> खोज ('' '। Apache_Solr_Service :: बचें ($ _ प्राप्त करें [' टेक्स्ट्सर्च '])। * * "~ 100', 0, 100, सरणी ('fq' => 'प्रकार: डेटाकोलेक्शन')); और यह अभी भी मेल नहीं खाता है। मैं खोज क्वेरी में ऐसा करना पसंद करूंगा और NGramFilterFactory का उपयोग नहीं करूंगा, –

+1

वाइल्डकार्ड प्रश्नों के साथ समस्या यह है कि वे क्वेरी समय के दौरान विश्लेषण नहीं करते हैं और इसलिए मेल नहीं खाते हैं। निचले मामले को खोजने का प्रयास करें क्योंकि आपके सूचकांक समय विश्लेषण में कम मामला है। – Jayendra

+0

यह या तो मदद करने के लिए प्रतीत नहीं होता था। क्या मुझे अपनी स्कीमा में कुछ करने की ज़रूरत है? –