Combining simple_query_string with range and fuzziness


(Aaron Gupta) #1

Hello All!

I have been having difficulty combining a simple_query_string, range, and the fuzziness field.

I can get all of them to work individually,

 "query": {
    "simple_query_string": {
      "query": "crit"
    }

and

 "query": {
    "filtered" : {
      "filter": {
        "range": {
          "time": {
            "gte": "11:00:00.123",
            "lte": "13:09:50.397"
          }
        }
      }
    }

But when i try to combine simple_query_string and the range, I would assume its something like this, but its not.

"filtered": {
    "query": {
      "simple_query_string": {
        "query": "crit"
      }
    },
    "filter" : {
      "range": {
          "time": {
            "lte": "15:12:50.123",
            "gte": "12:09:50.914"
          }
      }
    }
  }

Any suggestions on how to fix this query, or if this is even possible?

Thanks!


Combining query string query with range query
(Aaron Gupta) #2

Update, I probably need to use from and to within the range and not lte and gte.
I have tried another attempt and this is it:

{
  "filtered": {
    "query": {
      "match_all": {}
    },
    "filter": {
      "and": [
        {
          "range": {
            "time": {
              "from" : "11:00:00.123",
               "to": "13:09:50.394"
              }
            }
          },
          {
          "term" : {
            "priority": "CRIT"
          }
        }
      ]
    }
  }
}

(Aaron Gupta) #3

update 2:
figured it out. If any simpler ways, please suggest.

"query" : {
"filtered" : {
  "query" : {
    "query_string": {
      "query": "CRIT"
    }
  },
  "filter": {
    "range": {
        "time": {
          "from" : "11:00:00.123",
           "to": "13:09:50.394"
          }
        }
  }
}

}


(system) #4