Using ranges for timestamp in query string query - elasticsearch

I'm using query string query to retrieve data from api where NAME field equals TEST and its being updated TODAY.
Lastupdate field is timestamp format (2019-11-09 10:04:56.530000000)
I tried to do it this way, Which do not throw error but it clearly do not work as well, some of records are from months ago some of them yrs ago and I want to query only today.
/data/_search?q=name:TEST lastupdate:[now-1d/d TO now/D]
P.S I know how can I do it with query dsl with gte lt attributes of ranges but as I will be using this data in Power BI I have to feed json to it via URL so thats why I'm searching ways to do it in URI.

Maybe you're just missing an AND from your query param? Does the following give you your expected results?
GET /data/_search?q=name:TEST+AND+lastupdate:[now-1d/d+TO+now/d]

Related

Elastic search - Query String date search possibilities

I have date field in ES data and I want to make query string search, to get rows, where date value is from last 3 months. I can do that like this: (created_at:[2022-03-01 10:50:00 TO now]), but I'm looking for something like this - (created_at:[now-3M TO now]) Looks like now-3M syntax can't be used in query string search. Is there a way, to search last 3 months without adding a strict date from?

Store elasticsearch date across different timezones and query it without timezone

ONE elastic index that stores visitor data for restaurants in chennai and in New york.
The query must return data for 8-9am in chennai and 8-9am in newyork. Since the data is in one index, is there a way to ignore the timeszone in the timestamp and query elastic data?
or is it possible to solve this problem without multiple query?
The approach I am taking is to convert and store local date time (without timezone info) into a long integer yymmddhhmmss and query it. This will support lte and gte queries too.
it's not possible, no, because they are two totally different timezones/timestamps

How to get rows containing both date and "null" with ODATA filter query? (Power Automate)

I´ve been trying to create some customer reports but I keep getting stuck on trying to retrive rows that matches two arguments.
I need to retrive all rows containing both the OUT_DATETIME where it matches the current date and if the OUT_DATETIME is null. Now I have very little experience with ODATA filter queries but I´ve tried adding "or eq null" "or OUT_DATETIME eq null" "or null" after the expression without any luck.
This is how the filter query currently look:
https://i.stack.imgur.com/btgiS.png

Get distinct values from a field in ElasticSearch via a REST API URI

I have the following URI which should retrieve all values from the Gender field.
http://localhost:9200/persons/_search?_source=Gender
However, it does not return me all the data in the index of the Gender field. I want to get the data distinct also.
I am consuming this REST API in AngularJS. Can someone help me to achieve this type of URI query ?
Thank you.
Elasticsearch returns 10 hits by default, unless otherwise specified by size.
To get distinct values of a field use terms aggregation.
Refer: ES-return-unique-values

how to find the date range in uri request search in elasticsearch

I have a search in which i need to find the delta of data
http://localhost:9200/index/index_type/_search?q=sampledate[21-02-2015 TO 22-02-2015]
but this search is giving me error
could anybody help?
You can use below query:
GET /index_name/index_type/_search?q=dateCreated:[2016-01-06+TO+2016-01-07]
This will work only if dateCreated is a date field. Won't work with String
We had similar weird issue with this date field in Elastic Search 7.6.1.
We found working solution by removing colon(:) after date fields and surrounding entire date query part with brackets.
i.e.
GET /index_name/index_type/_search?q=dateCreated:[2016-01-06+TO+2016-01-07]
Above query changed to
GET /index_name/index_type/_search?q=(dateCreated[2016-01-06+TO+2016-01-07]) This should work

Resources