Search date in query string query

(Hayk Hovhanisyan) #1

ElasticSearch "2.4.4"
Java "1.8.0_151"

Hi there,

I am using query string query, and I need to have matching:

Data: "text" : "8 Derailed 2017-07-17 user user Dermot Mac Ateer 2017-07-03 2017-07-11"
User Input: 2017-07-17
Elastic query: { "query":{ "query_string":{ "query":"text:2017/17/07" } } }

Expected result: match all fields which have 2017-07-17

Expected result: match all data and not only those who have exact 2017-07-17 inside

thanks in advance.
regards Hayk Hovhannisyan

(David Pilato) #2

It depends of the analyzer you are using.

Try the _analyze endpoint to understand what is happening.

(Scott Carr) #3

Based on this example, it appears you would need to do a regex search, which would KILL performance depending on the number of records.

The regular expression would look something like:


If you could parse out the text, and add a date field, this would make searching a lot easier.

(Hayk Hovhanisyan) #4

Hi David,
by default as far as I understand used standard analyzer.
I also in my configurations have already implemented bigrams analyzer.

(Hayk Hovhanisyan) #5

Hi Scot,
My text filed type is String

This works: "query" : "text:\"2017-06-11\""
This not works 2017.07.17 - even if my field type is Date
"reason": "Invalid format: "2017.06.11" is malformed at ".06.11""

My worries that this is not best solution, because for same field I need to have complicated search, in order to search:

  • via free text search
  • via dates
  • via numbers
  • via wildcards
  • via partial text (with spaces)
  • via all this words
  • via exact matching

and so on.

Before we are using for some fields Regex search, for others Term or Match searches based on BA.

regards Hayk Hovhannisyan

(system) #6

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.