2

I'm using the attachment plugin: https://github.com/elastic/elasticsearch-mapper-attachments

I'm able to find documents with a specific word in 1 or more fields but unable to filter documents with a lower term frequency than searched for.

This works:

POST /crm/employee/_search
{
"query": {"filtered": {
    "query": {"match": {
       "employee.cv.content": "transitie"
    }}, 
    "filter": {
       "bool": {
           "should": [
              {"terms": {
                 "employee.listEmployeeType.id": [
                    2
                 ]
              }}
           ]
       }
   }
}},
"highlight": {"fields": {"employee.cv.content" : {}}}
}

After a long search, I've found the following:

"script": {
          "script": "crm['employee.cv.content'][lookup].tf() > occurrence",
          "params": {
              "lookup": "transitie",
              "occurrence": 1
          }
       },

I'm unable to implement it unfortunately. I hope i've explained the issue good enough for someone to give me a push in the right direction!

1 Answer 1

1
{
  "query": {
    "filtered": {
      "query": {
        "match": {
          "employee.cv.content": "transitie"
        }
      },
      "filter": {
        "bool": {
          "should": [
            {
              "terms": {
                "employee.listEmployeeType.id": [
                  2
                ]
              }
            }
          ],
          "must": [
            {
              "script": {
                "script": "_index['employee.cv.content'][lookup].tf() > occurrence",
                "params": {
                  "lookup": "transitie",
                  "occurrence": 1
                }
              }
            }
          ]
        }
      }
    }
  },
  "highlight": {
    "fields": {
      "employee.cv.content": {}
    }
  }
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.