Skip to content

Instantly share code, notes, and snippets.

@jayhilden
Created March 6, 2015 16:45
Show Gist options
  • Save jayhilden/899112a5d0fe09c5f1e9 to your computer and use it in GitHub Desktop.
Save jayhilden/899112a5d0fe09c5f1e9 to your computer and use it in GitHub Desktop.
DELETE index1
PUT index1
PUT index1/type1/_mapping
{
"properties": {
"Comments": {
"type": "nested",
"properties": {
"Description": {
"type": "string",
"analyzer": "english",
"fields": {
"folded": {
"type": "string"
}
}
}
}
},
"Description": {
"type": "string",
"analyzer": "english",
"fields": {
"folded": {
"type": "string"
}
}
},
"Title": {
"type": "string",
"analyzer": "english",
"fields": {
"folded": {
"type": "string"
}
}
}
}
}
GET index1/type1/_search
{
"query": {
"bool": {
"should": [
{
"multi_match": {
"query": "lisa",
"fields": [
"Title",
"Description"
],
"type": "cross_fields",
"operator": "and"
}
},
{
"nested": {
"path": "Comments",
"query": {
"filtered": {
"query": {
"match_all": {}
},
"filter": {
"exists": {
"field": "Comments.Description"
}
}
}
}
}
}
]
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment