http://www.elasticsearchtutorial.com/basic-elasticsearch-concepts.html
[ElasticSearch] Query DSL
curl - POST "http://localhost:9200/blog/_search?pretty=true" -d ‘
{"from": 0,
"size": 10,
"query" : QUERY_JSON,
FILTER_JSON,
FACET_JSON,
SORT_JSON
}’
Common Solr Queries in ElasticSearch Query DSL
Basic select, with specific field
http://www.elasticsearchtutorial.com/common-solr-queries-in-elasticsearch.html
http://localhost:8983/solr/select?q=lucene&fl=title
{
"query": {
"query_string": {
"query": "lucene",
"fields": ["title"]
}
}
}
Query fields (qf param)
http://localhost:8983/solr/select?q=lucene&fl=title&qf=title^10+body^2
"query": {
"query_string": {
"query": "lucene",
"fields": ["title^10","body^2"]
}
}
}
Filter queries (fq param)
http://localhost:8983/solr/select?q=lucene&fq=name:elastic&fq=name:search
"query": {
"filtered": {
"query": {
"query_string": {
"query": "lucene"
}
},
"filter": {
"and": [
{
"query": {
"query_string": {
"query": "name:elastic"
}
}
},
{
"query": {
"query_string": {
"query": "name:search"
}
}
}
]
}
}
}
}
Facets
http://localhost:8983/solr/select?q=lucene&facet=on&facet.fl=category{
"query": {
"query_string": {
"query": "lucene"
}
},
"facets": {
"category": {
"terms": {
"field": "category",
"size": 10
}
}
}
}
Geo-Spatial search (within x km of a point)
http://localhost:8983/solr/select?q=*:*&fq={!geofilt pt=45.15,-93.85 sfield=store d=25}
"query": {
"filtered": {
"query": {
"match_all": {}
},
"filter": {
"geo_distance": {
"distance": "25km",
"pin.location": {
"lat": 45.15,
"lon": -93.85
}
}
}
}
}
}
참고할 싸이트
[Querying ElasticSearch - A Tutorial and Guide]http://okfnlabs.org/blog/2013/07/01/elasticsearch-query-tutorial.html#filter-on-one-field
[easy-to-use Javascript Library for ElasticSearch ]http://okfnlabs.org/projects/elasticsearch-js/
- Terms - counts by distinct terms (values) in a field
- Range - counts for a given set of ranges in a field
- Histogram and Date Histogram - counts by constant interval ranges
- Statistical - statistical summary of a field (mean, sum etc)
- Terms Stats - statistical summary on one field (stats field) for distinct terms in another field. For example, spending stats per department or per region.
- Geo Distance: counts by distance ranges from a given point
'BigData' 카테고리의 다른 글
Power BI에 대해 알아야 할 사항 (0) | 2017.06.20 |
---|---|
Apache Spark로 집계하기 클러스터 컴퓨팅으로 집계 해결 (2) (0) | 2017.06.14 |
Apache Spark로 집계하기 클러스터 컴퓨팅으로 집계 해결 (1) (0) | 2017.06.14 |
[ElasticSearch] - aggregration query (0) | 2014.10.13 |
fluentd + elasticsearch 설치 하기 (0) | 2014.09.24 |
install ElastSearch (0) | 2014.09.03 |
오라클 Charset 변경 해야 하는 이유와 방법 (0) | 2014.04.11 |