Tuesday, 29 March 2022

Elastic Search query_string Query

Query string query:

query_string query to create a complex search that includes wildcard characters searches across multiple fields
This query uses syntax to parse and split the provided query string based on operators, such as AND or NOT

Sample Queries:
GET /_search
{
  "query": {
    "query_string": {
      "query": "(new york city) OR (big apple)",
      "default_field": "content"
    }
  }
}

GET /_search
{
  "size": 10,
    "sort": [
    {
      "date": {
        "order": "desc"
      }
    }
  ],
  "query": {
    "query_string": {
      "query": "(IP:\"\" AND URI:*API*)"
    }
  }
}
Match
GET /_search
{
  "query": {
         "match" : {
            "URI" : "/index.html"
        }
  },
  "size": 10,
  "sort": [
    {
      "date": {
        "order": "desc"
      }
    }
  ]
}


Term

GET /_search
{
  "size": 10000,
  "sort": [
    { "date": "desc" }
  ], 
  
"query": {
    "bool": {
        "must" : [
          {
           "term": {
             "name": "Bob"
           }
         },
         {
           "term": {
             "gender": "male"
           }
         }
       ]
     }
   }
}

No comments:

Post a Comment

What should you required to learn machine learning

  To learn machine learning, you will need to acquire a combination of technical skills and domain knowledge. Here are some of the things yo...