Skip to content

Instantly share code, notes, and snippets.

@malteos
Created January 25, 2017 11:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save malteos/c49889e4820762d29592f26a08d48ef2 to your computer and use it in GitHub Desktop.
Save malteos/c49889e4820762d29592f26a08d48ef2 to your computer and use it in GitHub Desktop.

Returns only 'Main Page'

curl -XPOST localhost:9200/wiki_content/_search?pretty -d '
{
  "_source": [
    "title"
  ],
  "query": {
    "bool": {
      "should": [
        {
          "term": {
            "title.keyword": {
              "boost": 100,
              "value": "Main Page"
            }
          }
        }
      ],
      "minimum_number_should_match": 1,
      "filter": [
        {
          "bool": {
            "must": [
              {
                "terms": {
                  "namespace": [
                    0
                  ]
                }
              }
            ]
          }
        }
      ]
    }
  }
}'

Returns 'Main Page' and other pages with namespace=0

curl -XPOST localhost:9200/wiki_content/_search?pretty -d '
{
  "_source": [
    "title"
  ],
  "query": {
    "bool": {
      "should": [
        {
          "term": {
            "title.keyword": {
              "boost": 100,
              "value": "Main Page"
            }
          }
        }
      ],      
      "filter": [
        {
          "bool": {
            "must": [
              {
                "terms": {
                  "namespace": [
                    0
                  ]
                }
              }
            ]
          }
        }
      ]
    }
  }
}'```
@nomoa
Copy link

nomoa commented Jan 25, 2017

But we should not put the filter in the same bool, it's maybe a bug when we try to compact the bool query as an optimization step...
I think it's not up to you to set this param...
I'll try to find time to investigate, if I don't find a solution to fix cirrus I'm fine keeping it in your Feature class if it works for your usecase.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment