2013-12-23 2 views
4

이 문제가 해결되었습니다. 내가 원하는 것은 다중 값에 대한 질의를하고 적어도 값이 올랐는지 확인하는 것입니다. 예를 들어 필드는 "FREE"또는 "FREE", "IN_USE"가 아닌 "FREE", "FREE"여야합니다.단일 키워드에 대한 Solr 쿼리 검색으로

Field 
<field name="point_statusses" type="string" indexed="true" stored="true" multiValued="true" /> 

Type 
<fieldType name="string" class="solr.StrField" sortMissingLast="true" /> 

SQL 
GROUP_CONCAT(cp.status) as point_statusses 

명확한 설명 :

내가 여러 개의 플러그를 가지고 있으며, 그 모두가 무료, IN_USE 또는 오류의 상태가 객체를 가지고있다. 내가 뭘하고 싶은 건 자유 상태로 두 개의 플러그가있는 것들을 걸러 내고 schema.xml의 구조를 바꿀 수 없어요. 이 질문에 어떻게 대답합니까?

+1

_solheme.xml에서 _schema.xml_ 및 쿼리 처리기의'fields' 및'types'을 추가 할 수 있습니까? – cheffe

+0

도와 주시면 감사하겠습니다.) – Xavier

답변

2

solr.StrField는 용어 빈도 정보를 보존하지 않으므로 안타깝게도 스키마를 변경하지 않으면 완료 할 수 없습니다.

견적의 schema.xml 에서 : 당신은 몇 가지 변경 사항을 적용 할 수있는 경우

... 
    1.2: omitTermFreqAndPositions attribute introduced, true by default 
     except for text fields. 
    ... 

그러나, 그 다음이 작동합니다 (SOLR 4.5.1에서 테스트) :

1) 스키마에 대해 다음 변경 사항 중 하나를 수행하십시오.

  • 필드를 text_general로 변경하십시오 (또는 임의의 solr.TextField 필드); 용어 주파수에 의해
<field name="point_statusses" type="string" indexed="true" stored="true" multiValued="true" omitTermFreqAndPositions="false"/> 

2) 필터 :

<field name="point_statusses" type="text_general" indexed="true" stored="true" multiValued="true" /> 
또는 추가 omitTermFreqAndPositions="false"는 정의를 point_statusses합니다. 예 :

{!frange l=2 u=2}termfreq(point_statusses,'FREE') 

또는 2 ~ 3 '무료'point_statusses에서 :

{!frange l=2 u=3}termfreq(point_statusses,'FREE') 

마지막 SOLR 쿼리 할 수있다 정확히 2 '무료'point_statusses을 가진

검색 문서 모양은 다음과 같습니다.

http://localhost:8983/solr/stack20746538/select?q=*:*&fq={!frange l=2 u=3}termfreq(point_statusses,'FREE') 
+0

감사합니다 !! 나는 이것에 나의 머리를 어 기고 있었다! – Xavier