본문으로 바로가기

Apache Solr 쿼리

category 색인/Apache Solr 2018. 8. 9. 17:41
반응형

Apache Solr 쿼리



검색 쿼리 parameter



sort  - 정렬과 관련된 파라미터

[Example]

 

parameterdescription
sort=score desc정확도를 높은데서 낮은데로 정렬한다.
sort=price ascprice필드를 오름차순 정렬
sort=inStock desc, price ascinStock필드를 내림차순 정렬한 후 price 필드를 오름차순 정렬한다.

 



start - 검색된 결과값중 몇번째일지 ( default : 0)

row - 결과값을 얼마나 출력할지

[Example]

 

parameterdescription
start=0&rows10첫번쨰 문서부터 총 10개의 문서를 출력한다.



fq (Filter Query) - 검색된 결과중 또 한번 쿼리에 부합하는 검색 결과를 찾는다. AND문과 다른점은 score(정확도)값에 영향을 주지 않는 것이다.


[Example]

만약 title 이라는 필드에 대해 실적으로 검색을 하여 두개의 문서가 나왔다고 하면


request )

[url]/select?q=title:실적 


result )

1) "title": "실적 악화보다 더 무서운 '담합 낙인'..건설사 신음"

2) "title": "1분기 항공여객 실적 2437만명, 전년 동기比 12.4%↑"

 

request )

[url]/select?q=title:실적&fq=title:건설사 


result )

1) "title": "실적 악화보다 더 무서운 '담합 낙인'..건설사 신음"


정확도에 영향을 끼치지 않고 메인쿼리와 독립되게 캐시되어있어 속도향상에도 영향을 준다고 한다.



fl (Field List) : 결과값의 필드를 제한을 둔다.

[Example]

parameterdescription
id name priceid, name, price 필드의 값만 리턴
id,name,priceid, name, price 필드의 값만 리턴
id name,priceid, name, price 필드의 값만 리턴
id scoreid필드 정확도 값만 리턴
*정확도 제외한 전체 필드 리턴
* score전체 필드와 정확도 리턴
[exaplain]검색결과에 대한 정확도 등의 정보가 리턴


그리고 사용자 정의를 통해 결과필드를 커스터마이징 할 수 있는데 결과값을 필드나 함수등을 이용하여 변경할 수 있다.

[Example]


request)

fl=id,sales_price:price,secret_sauce:prod(price,popularity),why_score:[explain style=nl]


response)

"response":{"numFound":2,"start":0,"docs":[ { "id":"6H500F0", "secret_sauce":2100.0, "sales_price":350.0, "why_score":{ "match":true, "value":1.052226, "description":"weight(features:cache in 2) [DefaultSimilarity], result of:", "details":[{

....


debug

debug=query : 오직 쿼리의 디버그 정보만 반환

debug=timing: 쿼리를 처리하는데 걸린시간에 대한 정보를 반환

debug=results: 검색결과에 대한 정확도정보를 반환한다. (fl=[explain] 같은)

debug=all: 위의 모든 디버깅 정보를 반환한다.



wt (Response Writer)


Reference에는 이런것들이 있다고 하는데 안되는게 몇개 있다

 

csvCSVResponseWriter
jsonJSONResponseWriter
phpPHPResponseWriter
phpsPHPSSerializedResponseWriter
pythonPythonResponseWriter
rubyRubyResponseWriter
smileSmileResponseWriter
velocityVelocityResponseWriter
xmlXMLResponseWriter
xsltXSLTResponseWriter


[Example]

wt=json



반응형

'색인 > Apache Solr' 카테고리의 다른 글

SOLR 한글 웹문서 색인을 위한 Tokenizer, Filter세팅방법  (0) 2017.10.24
Solr 스키마  (0) 2017.10.24