Skip to content

Instantly share code, notes, and snippets.

@drewr
Last active August 29, 2015 14:02
Show Gist options
  • Save drewr/13ba55295f4430d076d2 to your computer and use it in GitHub Desktop.
Save drewr/13ba55295f4430d076d2 to your computer and use it in GitHub Desktop.
Bool filter with whitespace analyzer
curl -s -XDELETE localhost:9200/damjan >/dev/null
curl -s -XPUT localhost:9200/damjan -d'---
settings:
index.number_of_shards: 1
index.number_of_replicas: 0
mappings:
t:
properties:
appname:
type: string
analyzer: whitespace
'
curl -s localhost:9200/damjan/_analyze\?format=yaml\&field=appname\&text=api-v2
curl -s -XPOST localhost:9200/damjan/t\?refresh -d'---
appname: api
'
curl -s -XPOST localhost:9200/damjan/t\?refresh -d'---
appname: api-v2
'
curl -s localhost:9200/damjan/_search -d'---
query:
filtered:
query:
match_all: {}
filter:
bool:
must:
term:
appname: api
must_not:
term:
appname: api-v2
'
# alternatively (with potentially more memory consumption)
curl -s localhost:9200/damjan/_search -d'---
query:
filtered:
query:
match_all: {}
filter:
regexp:
appname: "api"
'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment