Created
March 12, 2013 19:53
-
-
Save sihutch/5146380 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
curl -XDELETE 'http://localhost:9200/exp/' | |
#Create the index | |
curl -XPUT 'http://localhost:9200/exp/' | |
#Configure the mapping | |
curl -XPUT localhost:9200/exp/content/_mapping -d ' | |
{ | |
"content": { | |
"properties": { | |
"contributors": { | |
"type": "nested", | |
"properties": { | |
"contributorRole": { | |
"type": "multi_field", | |
"fields": { | |
"contributorRole": { | |
"type": "string", | |
"index": "analyzed" | |
}, | |
"untouched": { | |
"type": "string", | |
"index": "not_analyzed" | |
} | |
} | |
} | |
} | |
}, | |
"identifiers": { | |
"type": "nested", | |
"properties": { | |
"identifierType": { | |
"type": "multi_field", | |
"fields": { | |
"identifierType": { | |
"type": "string", | |
"index": "analyzed" | |
}, | |
"untouched": { | |
"type": "string", | |
"index": "not_analyzed" | |
} | |
} | |
} | |
} | |
} | |
} | |
} | |
}' | |
#Index a doc | |
curl -X PUT "http://localhost:9200/exp/content/1" -d ' | |
{ | |
"title": "Test Title", | |
"contentType": "Test Content Type", | |
"publisher": "Publisher", | |
"contributors": [ | |
{ | |
"contributorRole": "contributor role 1", | |
"contributorName": "Contributor 1" | |
}, | |
{ | |
"contributorRole": "contributor role 2", | |
"contributorName": "Contributor 2" | |
} | |
], | |
"identifiers": [ | |
{ | |
"identifierType": "Test Identifier Type 1", | |
"identifierValue": "Test Identifier Value1" | |
}, | |
{ | |
"identifierType": "Test Identifier Type 2", | |
"identifierValue": "Test Identifier Value2" | |
} | |
] | |
}' | |
#Search and request facets | |
curl -X POST "http://localhost:9200/exp/content/_search?pretty=true" -d ' | |
{ | |
"query": { | |
"query_string": { | |
"query": "test" | |
} | |
}, | |
"facets": { | |
"contributors.contributorRole.untouched": { | |
"terms": { | |
"field": "contributors.contributorRole.untouched" | |
}, | |
"nested": "contributors" | |
}, | |
"identifiers.identifierType.untouched": { | |
"terms": { | |
"field": "identifiers.identifierType.untouched" | |
}, | |
"nested": "identifiers" | |
} | |
} | |
}' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment