Delete documents with a missing field in elastic search - elasticsearch

I want to delete documents not having a specific field in elastic search. I tried combination of must_not and exists but its giving documents in which the field is there but its null.But i want the docs in which the field is not present at all.

Related

ElasticSearch: how to search from multiple indexes

I have a situation where I need to search from multiple indexes (products and users). Below is a sample query I am using to do that search
http://localhost:9200/_all/_search?q=*wood*
http://localhost:9200/users,products/_search?q=*wood*
With the above API request, it only returns search results for the product index. But if I search using the below API it returns search results for users index
http://localhost:9200/users/_search?q=*wood*
As you can see I am passing same value for "q" parameter. I need to search for both product and users index and check if there is the word "wood" in any attribute in both indexes. How can I achieve this
You can pass multiple index names instead of _all as it will search in other indices that you don't intent to by using the comma seprated index name like
http://localhost:9200/users,products/_search?q=*wood*
Although, _all should also fetch the result from users index which you get when you specify its name, you need to debug why its happening, maybe increase the size param to 1000 as by default Elasticsearch returns only 10 results and it seems in case of _all all the top results coming from products index only.

Aggregation on mapping in elastic

I want to apply aggregation in elastic on field count
Example:
domain:["config","test"] <----- field
I want to check that how many times this domain is present in docs.
you can use the terms aggregation on the domain field, but you need to make sure that domain field or its subfield is of the keyword type.

elasticsearch find documents that missing or have particular value

I wonder how do I filter documents in elastic search that doesn't have particular field or have this field with particular value.
example, I have a doc which may have the field "only2".
and I query for all the docs, that have this field equals to my username and the whole the docs that are not set to my username (meaning I set it to be public)

Are ElasticSearch document IDs scored?

If the mapping of a document is set to analyzed, it's scored and then relevant results are returned on a query. Are document IDs (_id) scored too?
I need to perform an exact ID match on a analyzed document and cannot change the type to non-analyzed since I'm unable to dump the data already in that index.
Will making a query with a specific ID return the exact match?
Document ID's are not scored in elasticsearch.
So index/type/id will fetch the exact document with given id
From docs:
Each document indexed is associated with a _type (see the section
called “Mapping Typesedit”) and an _id. The _id field is not indexed.

Grouping documents based on named and Lat ,long in Elastic Search

I wanted to group documents based on Name and Lat, Lang in Elastic Search.I explored the aggregations API but it gives only a count for a specific criteria not the actual documents.Is there a way in which we can do this in Elastic Search
you could use nested aggregations - something like aggregate by name, _id. And use second query to get document by ids.

Resources