Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Next revisionBoth sides next revision
courses:cs397:winter2017:elasticsearch [2017/03/27 17:18] – [Viewing Data] admincourses:cs397:winter2017:elasticsearch [2017/03/27 17:22] – [Filtering Results] admin
Line 22: Line 22:
  
   curl –XGET ‘localhost:9200/index/_search?pretty’   curl –XGET ‘localhost:9200/index/_search?pretty’
 +
 +==== Filtering Results ====
 +
 +Only get results that match certain criteria: 
 +
 +  curl -XGET 'localhost:9200/index/_search?pretty' -H 'Content-Type: application/json' –d’{"query": { "match": { "field": "value" } } }'
 +
 +
 +  curl -XGET 'localhost:9200/index/_search?pretty' -H 'Content-Type: application/json' –d’{ "query": {
 +    "bool": {
 +      "must": [
 +        { "match": { "address": "mill" } },
 +        { "match": { "address": "lane" } }
 +        ]
 +      }
 +    }
 +  }'
  
 ==== Sorting Examples ==== ==== Sorting Examples ====
Line 32: Line 49:
  
   curl -XGET 'localhost:9200/index/_search?pretty' -H 'Content-Type: application/json' -d’   curl -XGET 'localhost:9200/index/_search?pretty' -H 'Content-Type: application/json' -d’
-+  
-  "query": { "match_all": {} }, +    "query": { "match_all": {} }, 
-  "sort":+    "sort":
-    { "field": "asc"+      { "field": "asc"
-  +    
-}'+  }
 +   
 +==== Limiting Results ==== 
 + 
 +Only give one result back from searching ''index'':  
 + 
 +  curl -XGET 'localhost:9200/index/_search?q=*&size=1&pretty' 
 +   
 +Give back one result, starting at search result 10, from ''index'' 
 + 
 +  curl -XGET 'localhost:9200/bank/_search?q=*&size=1&from=10&pretty'
  
 ===== Adding Information ===== ===== Adding Information =====
courses/cs397/winter2017/elasticsearch.txt · Last modified: 2017/04/16 19:26 by admin
CC Attribution-Noncommercial-Share Alike 4.0 International
Driven by DokuWiki Recent changes RSS feed Valid CSS Valid XHTML 1.0