2015-01-29 1 views
0

나는 사소한 일을하지 않았으며 스핑크스 나 솔르가 그것을 해결할 수있는 올바른 도구인지 이해하고 싶다. 단순화 된 예 : 내 사이트에 제품 설명별로 검색 할 수있는 검색 필드가 있습니다. mysql db의 다음 설명 :문구로 대부분의 일반적인 문구 검색

Id Desc 
1 this is my test document number one. also checking search within phrases. 
2 this is my test document number two 
3 this is another group 
4 this is first group 
5 this is first test 
6 this is your test 

사용자가 검색 필드에 일부 텍스트를 입력 할 때. "is"는 다음 결과를 얻어야합니다 ("is"를 포함하는 상위 3 개 구). "this is", "is my", "is first"입니다.

다른 사람이 어떻게 할 수 있습니까? 어쩌면 지금 내 요구 사항에 맞는 더 나은 검색 엔진을 사용할 수 있습니까?

<fieldType class="solr.TextField" name="text_auto"> 
<analyzer type="index"> 
    <tokenizer class="solr.StandardTokenizerFactory"/> 
    <filter class="solr.LowerCaseFilterFactory"/> 
    <filter class="solr.ShingleFilterFactory" maxShingleSize="4" outputUnigrams="true" outputUnigramsIfNoShingles="false" /> 
</analyzer> 
<analyzer type="query"> 
    <tokenizer class="solr.StandardTokenizerFactory"/> 
    <filter class="solr.LowerCaseFilterFactory"/> 
    <filter class="solr.StandardFilterFactory"/> 
    <filter class="solr.RemoveDuplicatesTokenFilterFactory"/> 
</analyzer> 
</fieldType> 

<field name="title" type="text_auto" indexed="true" stored="true"/> 
<field name="content_autosuggest" type="text_auto" indexed="true" stored="true" multiValued="false"/> 

<copyField source="title" dest="content_autosuggest"/> 

답변

1

ShingleFilter을 사용해보세요. 위키의 예와 같이 2로 maxShingleSize 및 mixShingleSize 모두를 설정하면, 당신이 얻을 :

this is my test document => this is, is my, my test, test document 

(적절한 토크 나이 및 기타 분석기를 사용해야합니다, 전에 싱글 필터에 필요한 경우 .)

그런 다음 당신은이 분야에서이 같은 정규식 검색을 수행 할 수 있습니다 모든 문서를 반환해야합니다

shingle_field:/(is .*)|(.* is)/ 

합니다. (I 위키 상태 때문에이 작업을한다고 생각 : 는 단일 토큰으로 토큰의 조합을 생성합니다.)

는 수를 얻을 수있는 facet query를 사용하여 다음과 같은 경우

shingle_field:/(is .*)|(.* is)/&facet=true&facet.field=shingle_field 

(rows=0 추가 문서에 관심이없고 패싯 만 필요합니다.)

+0

감사합니다. Arun. 이 필터를 사용해 보겠습니다. –

+0

접두어로만 패싯 쿼리를 검색하는 것처럼 보입니다. 전의. "is"를 찾으려고하면 "this is"가 반환되지 않습니다. –

+0

qn을 정의한 필드의 fieldType으로 업데이트하십시오. – arun