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

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.

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.

How to filter the aggregation results in Kibana (elastic search)?

I want to filter the elastic search aggregation results in Kibana (v6.2). For example, I want to show only sum of hours those that are more than 100 (like HAVING command in SQL). I know that we can filter the results in filter section over other fields, but I don't know how to apply the filter on aggregation functions. I tried to use post_filter in filter section in Kibana, but it didn't work.
Any ideas?
You can augment aggregation query within advanced field
It will be added to request as shown on picture
Another question is what to put into this field. You can check script values for sum aggregation

How to return term scores in elasticsearch?

How do I get the term vector for an indexed document in elasticsearch?
That is, once I have uploaded several documents to my elasticsearch index, I would like to get the scored term vectors back so that I can see which which terms are over indexed for a given document and thus for a document show the most influential terms.
Is this possible?
You can achieve that using the Term Vectors API: https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-termvectors.html
Say you already indexed several documents. Then it's possible to get the term vectors using the following API call:
curl -XGET 'http://localhost:9200/twitter/tweet/<id>/_termvectors?pretty=true'
Just replace <id> with the id of the document you want create the query for.

elasticsearch: how can i boost documents having sub-objects

How can i boost documents having sub-objects over documents without having such sub-objects even if i don't query directly for information of sub-objects?
Here an example:
I put events in my search index. Each event has a name and optional one ore more dates. you can search for events by name. I want the matching events with dates to become the first results. Events that also match by name but don't have a date should come afterwards.
You can create "has_dates" field and use boosting query boosting objects with "has_dates" field.

Resources