Questions tagged [elasticsearch-query]

Elasticsearch provides a full Query DSL based on JSON to define queries. In general, there are basic queries such as term or prefix. There are also compound queries like the bool query. Queries can also have filters associated with them such as the filtered or constant_score queries, with specific filter queries.

Elasticsearch provides a full Query DSL based on JSON to define queries. In general, there are basic queries such as term or prefix. There are also compound queries like the bool query. Queries can also have filters associated with them such as the filtered or constant_score queries, with specific filter queries.

Certain queries can contain other queries (like the bool query), others can contain filters (like the constant_score), and some can contain both a query and a filter (like the filtered). Each of those can contain any query of the list of queries or any filter from the list of filters, resulting in the ability to build quite complex (and interesting) queries.

634 questions
36
votes
2 answers

Multi-"match-phrase" query in Elastic Search

this should be obvious to me but is not. The following two-match only the second phase (in this case, Cape Basin) "query": { "match_phrase": { "contents": { "query": "St Peter Fm", "query": "Cape Basin" …
punkish
  • 13,598
  • 26
  • 66
  • 101
21
votes
4 answers

elasticsearch group-by multiple fields

I am Looking for the best way to group data in elasticsearch. Elasticsearch doesn't support something like 'group by' in sql. Lets say I have 1k categories and millions of products. What do you think is the best way to render a complete category…
timg
  • 501
  • 2
  • 4
  • 13
20
votes
5 answers

How to request a single document by _id via alias?

Is it possible to request a single document by its id by querying an alias, provided that all keys across all indices in the alias are unique (it is an external guarantee)?
Mischa Arefiev
  • 5,227
  • 4
  • 26
  • 34
18
votes
1 answer

Elasticsearch: is bulk search possible?

i know there is support for bulk index operation. but is it possible to do the same for search queries? i want to send many different unrelated queries (to do precision/recall testing) and it would probably be faster using bulk query
piotrek
  • 13,982
  • 13
  • 79
  • 165
17
votes
3 answers

Is it possible to put a comment in an Elasticsearch query?

Is it possible to put a comment into an Elasticsearch query JSON? I want to be able to add some extra text to the query that's human-readable but ignored by Elasticsearch. For example, if I have the following query: { "query": { "match_all": {} }…
16
votes
3 answers

log JSON queries built through ElasticSearch High Level Java Client for debugging?

I use ElasticSearch High-Level Client Java API in my Spring Boot application. I want to log the queries built using High-Level client API for debugging purposes. My question is what kind of settings required in my application.properties file to turn…
12
votes
1 answer

ES returns only 10 records by default. How to get all records without using scroll API

When we query ES for records it returns 10 records by default. How can I get all the records in the same query without using any scroll API. There is an option to specify the size, but size is not known in advance.
Ajinkya Dhote
  • 1,389
  • 3
  • 13
  • 26
11
votes
2 answers

Edge NGram with phrase matching

I need to autocomplete phrases. For example, when I search "dementia in alz", I want to get "dementia in alzheimer's". For this, I configured Edge NGram tokenizer. I tried both edge_ngram_analyzer and standard as the analyzer in the query body.…
srgbnd
  • 5,404
  • 9
  • 44
  • 80
10
votes
1 answer

Elasticsearch Go nested query

I'm using olivere's elastic Go library to run Elastic queries - https://godoc.org/github.com/olivere/elastic#NestedQuery The data I'm trying to query on looks like this: "_source": { "field1": "randVal1", …
covfefe
  • 2,485
  • 8
  • 47
  • 77
9
votes
3 answers

Searching subtitle data in elasticsearch

Having the following data (simple srt) 1 00:02:17,440 --> 00:02:20,375 Senator, we're making our final 2 00:02:20,476 --> 00:02:22,501 approach into Coruscant. ... what would be the best way to index it in Elasticsearch? Now here's the catch: I…
8
votes
1 answer

How to do a case-insensitive search on a keyword field in Elasticsearch without reindexing?

I have a keyword field like this: "address": { "type": "keyword" } The value is written in camel-case, as it's intended for display. e.g "1/10 Somewhere Rd, Somewhere AAA 3333" Now, i want to do a case-insensitive search on that field, ideally…
RPM1984
  • 72,246
  • 58
  • 225
  • 350
7
votes
2 answers

What is difference between match and bool must match query in Elasticsearch

What is the difference between Only match and bool must match query in ES? First, Only use the match query { "query":{ "match":{ "address":"mill" } } } Second, use compound query { "query": { "bool": { …
Johnson
  • 147
  • 2
  • 7
7
votes
1 answer

scoring of Term vs. Terms query different

I am retrieving documents by filtering and using a term query to apply a score. The query should match all animals having a specified color - the more colors are matched, the higher the score of a doc. Strange thing is, term and terms query result…
nonNumericalFloat
  • 1,348
  • 2
  • 15
  • 32
6
votes
3 answers

Dense vector array and cosine similarity

I would like to store an array of dense_vector in my document but this does not work as it does for other data types eg. PUT my_index { "mappings": { "properties": { "my_vectors": { "type": "dense_vector", "dims": 3 …
Leo
  • 5,013
  • 1
  • 28
  • 65
6
votes
2 answers

Elastic Search match phrase query -> output not predictable

Sample doc { "id": 5, "title": "Quick Brown fox jumps over the lazy dog", "genre": [ "fiction" ] } Mapping { "movies" : { "mappings" : { "properties" : { "genre" : { "type" : "text", "fields" : { …
Sahil Gupta
  • 2,028
  • 15
  • 22
1
2 3
42 43