logo
down
shadow

Elastic search More like this query with filter is adding results


Elastic search More like this query with filter is adding results

By : Anor
Date : October 16 2020, 03:08 PM
hope this fix your issue This is a great example of why consistent indentation is important. Here, I've modified what you've posted with consistent indentation, and the problem is much more apparent (JSONLint is a handy tool, if you aren't using an editor that helps with this):
code :
{
  "query": {
    "filtered": {
      "query": {
        "more_like_this": {
          "fields": ["tags"],
          "like": ["t1", "t2"],
          "min_term_freq": 1,
          "min_doc_freq": 1
        },
        "filter": {
          "bool": {
            "must": [{
              "match": {
                "category": "cat1"
              }
            }]
          }
        }
      }
    }
  }


Share : facebook icon twitter icon
Elastic search filter query with bool returns invalid results

Elastic search filter query with bool returns invalid results


By : user3204995
Date : March 29 2020, 07:55 AM
I wish did fix the issue. I'm using Elastic search in Laravel. , This is your trouble spot:
code :
                    'must' => [
                        'term' => [
                            'type' => 11
                        ],
                        'term' => [
                            'public' => 1
                        ]
                    ]
                    'must' => [
                        [
                            'term' => [
                                'type' => 11
                            ]
                        ],
                        [
                            'term' => [
                                'public' => 1
                            ]
                        ]
                    ]
elastic search query parsing exception when adding term filter

elastic search query parsing exception when adding term filter


By : Nagaraj Kammar
Date : March 29 2020, 07:55 AM
I wish did fix the issue. Inside your filter, you need a bool filter if you have more than one constraints, which is your case, since you have a query filter and a term filter. So the correct way of doing it is like this:
code :
{
  "query": {
    "filtered": {
      "query": {
        "bool": {
          "must": [
            {
              "terms": {
                "status_type": [
                  "1",
                  "2",
                  "7"
                ]
              }
            }
          ]
        }
      },
      "filter": {
        "bool": {               <---- add this
          "must": [             <---- and this
            {
              "query": {
                "query_string": {
                  "fields": [
                    [
                      "name",
                      "message"
                    ]
                  ],
                  "query": "Arnold AND Schwarz"
                }
              }
            },
            {
              "term": {
                "language": "Austrian"
              }
            }
          ]
        }
      }
    }
  },
  "sort": [
    {
      "total": {
        "order": "desc"
      }
    }
  ]
}
{
  "query": {
    "filtered": {
      "query": {
        "query_string": {
          "fields": [
            [
              "name",
              "message"
            ]
          ],
          "query": "Arnold AND Schwarz"
        }
      },
      "filter": {
        "bool": {
          "must": [
            {
              "terms": {
                "status_type": [
                  "1",
                  "2",
                  "7"
                ]
              }
            },
            {
              "term": {
                "language": "Austrian"
              }
            }
          ]
        }
      }
    }
  },
  "sort": [
    {
      "total": {
        "order": "desc"
      }
    }
  ]
}
Elastic Search: filter query results by entry its field into another query results

Elastic Search: filter query results by entry its field into another query results


By : Sean.x.Hou
Date : March 29 2020, 07:55 AM
I wish did fix the issue. I found the question about the IN equivalent operator: , First step - get all relevant ids from reserved index:
code :
{
  "size": 0,
  "query": {
    "bool": {
      "must": [
        {
          "term": {
            "type": "TYPE_HERE"
          }
        }
      ]
    }
  },
  "aggregations": {
    "ids": {
      "terms": {
        "field": "id"
      }
    }
  }
}
{
  "query": {
    "bool": {
      "must": [
        {
          "terms": {
            "id": [
              "ID_1",
              "ID_2",
              "AND_SO_ON..."
            ]
          }
        }
      ]
    }
  }
}
elastic search Nested query filter based on date is not returning correct results

elastic search Nested query filter based on date is not returning correct results


By : Dani T
Date : March 29 2020, 07:55 AM
it should still fix some issue You need to think of nested fields as part of the parent record. Let's take the following example, I insert a single record that has 2 nested properties, one with a time of "2018-01-01T00:00:00Z" and one with a time of "2018-01-02T00:00:00Z"
Insert command:
code :
POST jaytest/webbrowsererror
{
  "projectId": "******************",
  "sId": "bt82x3g8v1505001600027",
  "pId": "bt82x3g8v1505001600027.1",
  "pageURL": "***************************",
  "startTime": 1505001600027,
  "country": "unknown",
  "size": 2,
  "errors": [
    {
      "sid": "bt82x3g8v1505001600027",
      "pid": "bt82x3g8v1505001600027.1",
      "browser": "Googlebot",
      "time": "2018-01-01T00:00:00Z",
      "errMsg": "Uncaught SyntaxError: Invalid regular expression: missing /",
      "url": "********************************",
      "lineNo": 161,
      "colNo": 54
    },
    {
      "sid": "bt82x3g8v1505001600027",
      "pid": "bt82x3g8v1505001600027.1",
      "browser": "Googlebot",
      "time": "2018-01-02T00:00:00Z",
      "errMsg": "Uncaught Error: Syntax error, unrecognized expression: #!",
      "url": "************************************************************",
      "lineNo": 3,
      "colNo": 69
    }
  ]
}
GET jaytest/webbrowsererror/_search
{
  "query": {
    "bool": {
      "must": [
        {
          "nested": {
            "path": "errors",
            "query": {
              "range": {
                "errors.time": {
                  "gte": "2018-01-02T00:00:00Z"
                }
              }
            }
          }
        }
      ]
    }
  }
}
How to filter out (exclude) all results given by Elastic search query DSL in Kibana?

How to filter out (exclude) all results given by Elastic search query DSL in Kibana?


By : user3002804
Date : March 29 2020, 07:55 AM
Hope that helps Use must_not clause of bool query as below:
code :
{
  "query": {
    "bool": {
      "must_not": [
        {
          "regexp": {
            "useragent": {
              "value": "Mozilla/5.0 \\(Windows.*"
            }
          }
        }
      ]
    }
  }
}
shadow
Privacy Policy - Terms - Contact Us © soohba.com