0

So I have the following sample JSON.

{
        "_index" : "prd-avi-chatbot-sales-fargate-2022.07.04",
        "_type" : "log",
        "_id" : "Xaksy4EB5R0ILwHLOelN",
        "_score" : 78.2336,
        "_source" : {
          "@timestamp" : "2022-07-04T21:44:37.060Z",
          "log" : """2022-07-04 21:44:37.059 - INFO  REQUESTS, sessionId: null, method: POST, httpStatus: 200 OK, uri: https://prd-avi-ms-chatbot-session.clarobrasil.mobi/users/, httpEntity: <{"id":null,"identity":"e9198a6c-ec93-4045-b44b-a8eb4fc4c904@tunnel.msging.net","info":{},"sessions":[{"id":null,"identity":"e9198a6c-ec93-4045-b44b-a8eb4fc4c904@tunnel.msging.net","configVersion":"0.0.0","input":{"id":"ABGHVRGVNjlYTwIQF8Ku2eErQa7iDaqqzaXk_A","to":"claroresidentialsales@msging.net","from":"e9198a6c-ec93-4045-b44b-a8eb4fc4c904@tunnel.msging.net","type":"text/plain","content":"Olá, quero conhecer as ofertas da Claro!","originChannel":"TUNNEL_TAKE","received":null,"processed":null,"sent":null,"metadata":{"#wa.timestamp":"1656971074","#uniqueId":"69516b5b-ab56-4861-ba4d-f86d4205e210","date_created":"1656971075713","uber-trace-id":"2202ecf56f4dcfb0%3A2202ecf56f4dcfb0%3A0%3A1","#tunnel.owner":"clarovendasrouter@msging.net","#tunnel.originator":"5511953639584@wa.gw.msging.net","#tunnel.originalFrom":"clarovendasrouter@msging.net/dalmata-iris2","#tunnel.originalTo":"claroresidentialsales%40msging.net@tunnel.msging.net/5511953639584%40wa.gw.msging.net"},"valid":true,"fromDesk":false},"currentStateId":null,"currentModuleCode":null,"currentStateIdAndEnabledTracking":false,"lastState":null,"lastInteraction":null,"processing":false,"project":{"id":"9fb5eae8-85e9-49b5-b5e0-60d791d26de7","name":null,"description":null},"active":false,"originChannel":"TUNNEL_TAKE","userPath":[],"created":null,"inputContent":"Olá, quero conhecer as ofertas da Claro!"}],"reprompt":false,"created":null,"updated":null},[Content-Type:"application/json"]>, response: {"buffer":[],"created":"2022-07-04T21:44:37.047","currentSession":null,"id":null,"identity":"e9198a6c-ec93-4045-b44b-a8eb4fc4c904@tunnel.msging.net","info":{},"project":null,"reprompt":false,"sessions":[{"active":true,"configVersion":"0.0.0","created":null,"currentModuleCode":null,"currentStateId":null,"currentStateIdAndEnabledTracking":false,"id":null,"identity":"e9198a6c-ec93-4045-b44b-a8eb4fc4c904@tunnel.msging.net","input":{"content":"Ol\u00E1, quero conhecer as ofertas da Claro!","from":"e9198a6c-ec93-4045-b44b-a8eb4fc4c904@tunnel.msging.net","id":"ABGHVRGVNjlYTwIQF8Ku2eErQa7iDaqqzaXk_A","metadata":null,"originChannel":null,"processed":null,"received":null,"sent":null,"to":"claroresidentialsales@msging.net","type":"text\/plain"},"lastInteraction":null,"lastState":null,"nlp":null,"originChannel":"TUNNEL_TAKE","processing":false,"project":"Project(id=9fb5eae8-85e9-49b5-b5e0-60d791d26de7, name=null, description=null)","userPath":[]}],"updated":null} """,
          "container_id" : "8cc5a8e282f64d8fa01d770c5ecdb4b1-254952119",
          "container_name" : "prd-avi-chatbot-sales-service",
          "source" : "stdout",
          "ecs_cluster" : "prd-avi",
          "ecs_task_arn" : "arn:aws:ecs:us-east-1:571186639223:task/prd-avi/8cc5a8e282f64d8fa01d770c5ecdb4b1",
          "ecs_task_definition" : "prd-avi-chatbot-sales:119"
        }
      }

And what I am basically doing is accessing the log index, and checking if it contains a specific word, that being the user id. The thing is I have lots of specifics ids, and I want to filter by some sort of array.

What I am currently doing is the following code.

{
  "query": {
    "bool": {
      "should": [
        {
          "match_phrase": {
            "log": "9a8de951-3ae7-4933-8da7-21232cb1a842@tunnel.msging.net"
          }
        },
        {
          "match_phrase": {
            "log": "7579c6c4-2271-4ea9-953f-d1317ccc6eb2@tunnel.msging.net"
          }
        },
        {
          "match_phrase": {
            "log": "daf329bd-7471-42ad-a26d-2055c0d4ba5a@tunnel.msging.net"
          }
        },
        {
          "match_phrase": {
            "log": "e9198a6c-ec93-4045-b44b-a8eb4fc4c904@tunnel.msging.net"
          }
        }
      ],
      "minimum_should_match": 1
    }
  }
}

is there a way on doing that on only one statement, kind of like doing multiple ors filter but with a given, "array" of ids.

I am a newbee on DSL itself, would appreciate some thorough explanation on the formulated query.

INGl0R1AM0R1
  • 1,532
  • 5
  • 16

0 Answers0