최대한 코드 변경을 schema.xml
및 기타 구성 파일로 제한하고 싶습니다. 다음과 같이Solr : 검색 결과가 변경되지 않는 퍼지 연산자
<field name="id" type="string" indexed="true" stored="true" required="true" multiValued="false" />
<field name="title" type="text_general" indexed="true" stored="true"/>
<field name="fact" type="string" indexed="true" stored="true" required="true" multiValued="false" />
<field name="body" type="text_exact_fuzzy" indexed="true" stored="true"/>
<copyField source="title" dest="text"/>
<copyField source="body" dest="text"/>
내 schema.xml
나중에 text_exact_fuzzy을 정의했습니다 : : 내 schema.xml
에 다음 코드를
<text_exact_fuzzy: field type for fuzzy matching -->
<fieldType name="text_exact_fuzzy" class="solr.TextField" omitNorms="false">
<analyzer type="index">
<tokenizer class="solr.StandardTokenizerFactory"/>
<filter class="solr.StandardFilterFactory"/>
<filter class="solr.LowerCaseFilterFactory"/>
<filter class="solr.EdgeNGramFilterFactory" minGramSize="2" maxGramSize="15"/>
</analyzer>
<analyzer type="query">
<tokenizer class="solr.StandardTokenizerFactory"/>
<filter class="solr.StandardFilterFactory"/>
<filter class="solr.LowerCaseFilterFactory"/>
<!--
<filter class="solr.PorterStemFilterFactory"/>
-->
<filter class="solr.PhoneticFilterFactory" encoder="DoubleMetaphone" inject="true"/>
</analyzer>
</fieldType>
내가 장고보기에서 쿼리를 만들어, 나는 (다음 코드를 사용하여 이는 물결표 표기법을 쿼리를 받아 추가 (예 : ~ 0.8) 쿼리의 각 단어의 끝 부분)에 : 아무리 내가을 설정하는 방법 그러나
fuzzy_clean_text = re.sub(r'\s', '~' + str(fuzzy_index) + ' ', clean_text + ' ')
#return fuzzy_clean_text
post_params = [('q', re.escape(json.dumps(fuzzy_clean_text))),
('wt','json'),
('fl', 'fact'),
# I've tried the query with and without the following parameter:
#('spellcheck.collate', 'true'),
]
result = urllib2.urlopen(solr_server_url, urllib.urlencode(post_params))
response = json.loads(result.read())
,이면 쿼리는 동일한 결과를 반환합니다. 또한, 퍼지 검색은 매우 관대하며 관련이없는 텍스트를 특정 fact
과 일치시키는 경우가 있습니다. 문제를 해결할 수있는 schema.xml
파일의 쿼리 매개 변수 또는 수정을 통해 다른 방법이 있습니까? 다른 stackoverflow 게시물을 ComplexPhraseQueryParser
제안하지만 내 코드베이스에 자바를 추가하고 싶지 않아 (그리고 어쨌든 이해하기가 꽤 어려워 보인다).
사례를 게시 할 수 있습니까? –