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
6
votes
1 answer

Elasticsearch default_operator "AND" not working as expected

I have setup my query string search with the "AND" default operator. My query is as follows: { "query": { "query_string" : { "query" : "Adam KT2 7AJ", "default_operator" : "AND" } } } I would expect…
Adam Lambert
  • 1,311
  • 3
  • 24
  • 45
6
votes
1 answer

Elasticsearch Aggregation: Sum of latest childrens per parent

Having a parent-children structure in Elasticsearch representing an order with order_revision children I want to generate a histogram of the price showing the sum of the quantity. { "_type": "order", "_id": "1063220887", "_score": 1, …
6
votes
3 answers

Remove duplicated records in ElasticSearch

I have millions of records in ElasticSearch. Today, I realized there are some records duplicated. Is there any way to remove these duplicated records? This is my query. { "query": { "filtered":{ "query" : { …
Sapikelio
  • 2,594
  • 2
  • 16
  • 40
5
votes
2 answers

Scroll in python Elasticsearch not working

I tried to scroll all documents with python when I query Elasticsearch so I can get over 10K results: from elasticsearch import Elasticsearch es = Elasticsearch(ADDRESS, port=PORT) result = es.search( index="INDEX", body=es_query, …
MicrosoctCprog
  • 460
  • 1
  • 3
  • 23
5
votes
1 answer

How do _search queries work in Elasticsearch?

The question is more around: "How do Elasticsearch nodes interact to give a specific search result and what is the flow of a search request?" I've referred to the following links to understand, but they aren't very clear, in what I am trying to…
jatin3893
  • 832
  • 1
  • 11
  • 24
5
votes
0 answers

get relevant data on elastic search

Need to apply search conditions on skills and years of experience on candidates below are the conditions Skills can be mandatory or non-mandatory if we apply skills as mandatory then search result should include records which have skills and…
5
votes
2 answers

How to handle nulls in an Elasticsearch index

I have a SQL table that I am exporting to Elasticsearch. One of the columns is a numeric field that is nullable, with nulls in some of the records. When we try to index the table, we get this error: One of the ETL (BigQuery -> ElasticSearch) jobs…
arcee123
  • 101
  • 9
  • 41
  • 118
5
votes
0 answers

Needs to return only the matched nested objects with full parent body in Elasticsearch

I am using Elastic search version 1.7 in my project. I have a an index named colleges and under this index there is a nested index name courses like this. { "name": "College Name" "university": "University Name", "city": 429, "city_name":…
5
votes
1 answer

How to make union query on Elasticsearch?

I would like to make a query with UNION and limit. I can explain that query on mysql. (SELECT * FROM table WHERE type='text' LIMIT 3 ) UNION (SELECT * FROM table WHERE type='word' LIMIT 3 ) I tried it on Elasticsearch { "query":{ …
USER
  • 741
  • 4
  • 10
  • 21
5
votes
1 answer

How to make use of `gt` and `fields` in the same query in Elasticsearch

In my previous question, I was introduced to the fields in a query_string query and how it can help me to search nested fields of a document. { "query": { "query_string": { "fields": ["*.id","id"], "query": "2" } } } But it…
Mehran
  • 15,593
  • 27
  • 122
  • 221
5
votes
2 answers

Query without using dynamic scripting

I have the following query which currently uses dynamic scripting. I have since found that my host doesn't support this, as it has wider reaching security implications. How would I rewrite this script so that it doesn't use dynamic script? { …
Mick Walker
  • 3,862
  • 6
  • 47
  • 72
4
votes
2 answers

Elasticsearch cannot find standalone reserved characters

I use Kibana to execute query elastic (Query string query). When i search a word include escapable characters (reserved characters like: '\', '+', '-', '&&', '||', '!', '(', ')', '{', '}', '[', ']', '^', '"', '~', '*', '?', ':', '/'). It will get…
4
votes
1 answer

Index on Elastic search contains and starts with search

We are using elastic search for faster searching on our organization data . The data model has organization id, address, organization name, business start date and organization contacts array . We have asked to perform string contains search and…
4
votes
2 answers

How to write a simple regexp query using elasticsearch in python?

I am trying to write a simple regexp query using elasticsearch in python that just won't work. Can anybody tell me where I'm going wrong ? result = es.search(index="my-index", body={"query": {"regexp": {"Name": "Vi.*" }}}) The indexed document is a…
4
votes
2 answers

How to do script sort on nested field with Elasticsearch?

I'm working with documents that looks like: { "product_name": "abc", "prices": { "regular": 9.99, "pricing_tables": [ { "id": 1, "price": 8.99 }, { "id": 2, "price": 7.99 } ] } } Where prices.pricing_tables is a nested…
Jimmy
  • 41
  • 3
1
2
3
42 43