Различия

Показаны различия между двумя версиями страницы.

Ссылка на это сравнение

Следующая версия
Предыдущая версия
system:elasticsearch:exaples:example-1 [2018/01/19 10:57] – создано mirocowsystem:elasticsearch:exaples:example-1 [2019/07/15 19:16] (текущий) mirocow
Строка 1: Строка 1:
 +{{tag>search indexer elasticsearch indexer}}
 +
 ====== how to match an array value by it's key in a key value pair elasticsearch array? ====== ====== how to match an array value by it's key in a key value pair elasticsearch array? ======
  
 +Create empty index "twitter" \\
 <code bash> <code bash>
 $ curl -XDELETE 'http://localhost:9200/twitter/' $ curl -XDELETE 'http://localhost:9200/twitter/'
 $ curl -XPUT 'http://localhost:9200/twitter/' $ curl -XPUT 'http://localhost:9200/twitter/'
 +</code>
 +
 +create geo_point mapping for the actual "tweet" \\
 +<code bash>
 $ curl -XPUT 'http://localhost:9200/twitter/tweet/_mapping' -d ' $ curl -XPUT 'http://localhost:9200/twitter/tweet/_mapping' -d '
 { {
Строка 30: Строка 37:
     }     }
 }' }'
 +</code>
  
 +Let's check if the mapping was set \\
 +<code bash>
 $ curl -XGET 'http://localhost:9200/twitter/tweet/_mapping?pretty=true' $ curl -XGET 'http://localhost:9200/twitter/tweet/_mapping?pretty=true'
 +</code>
 +
 +Post some tweets, with nested data \\
 +<code bash>
 $ curl -XPUT 'http://localhost:9200/twitter/tweet/1' -d '{ $ curl -XPUT 'http://localhost:9200/twitter/tweet/1' -d '{
     "name": "Athena",     "name": "Athena",
Строка 53: Строка 67:
     }     }
 }' }'
 +</code>
  
 +Query nested only \\
 +<code bash>
 $ curl -XGET localhost:9200/twitter/tweet/_search -d '{ $ curl -XGET localhost:9200/twitter/tweet/_search -d '{
     "query": {     "query": {
Строка 80: Строка 97:
     }     }
 }'; }';
 +</code>
  
 +Query "Athena" and "Oracle" \\
 +<code bash>
 $ curl -XGET localhost:9200/twitter/tweet/_search -d '{ $ curl -XGET localhost:9200/twitter/tweet/_search -d '{
     "query" : {     "query" : {
Строка 95: Строка 115:
     }     }
 }' }'
 +</code>
  
 +Combine the former two queries \\
 +<code bash>
 $ curl -XGET localhost:9200/twitter/tweet/_search -d '{ $ curl -XGET localhost:9200/twitter/tweet/_search -d '{
     "query" : {     "query" : {