Created
July 1, 2013 01:34
-
-
Save anonymous/5897829 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/properties' | |
curl -XPUT 'http://localhost:9200/properties' -d '{ | |
"settings": { | |
"number_of_shards": 3 | |
} | |
} | |
}' | |
curl -XPUT 'http://localhost:9200/properties/person/_mapping' -d '{ | |
"person": { | |
"_parent": { | |
"type": "property" | |
} | |
} | |
}' | |
curl -XPOST 'http://localhost:9200/properties/property/1' -d '{ | |
"address": "123 Fake St" | |
}' | |
curl -XPOST 'http://localhost:9200/properties/person/1?parent=1' -d '{ | |
"fullName": "John Smith" | |
}' | |
curl -XPOST 'http://localhost:9200/properties/person/2?parent=1' -d '{ | |
"fullName": "Bob Jones" | |
}' | |
curl -XPOST 'http://localhost:9200/properties/person/3?parent=1' -d '{ | |
"fullName": "Rob Bardon" | |
}' | |
curl -XPOST "http://localhost:9200/properties/_refresh" | |
curl -XPOST 'http://localhost:9200/properties/_search?pretty=true' -d ' | |
{ | |
"from": 0, | |
"size": 10, | |
"query": { | |
"bool": { | |
"must": [ | |
{ | |
"has_parent": { | |
"query": { | |
"bool": { | |
"must": { | |
"match": { | |
"address": { | |
"query": "123 Fake St", | |
"type": "boolean" | |
} | |
} | |
} | |
} | |
}, | |
"parent_type": "property", | |
"score_type": "score" | |
} | |
} | |
], | |
"should": [ | |
{ | |
"match": { | |
"fullName": { | |
"query": "John Smith", | |
"type": "boolean" | |
} | |
} | |
} | |
], | |
"minimum_should_match": "1" | |
} | |
}, | |
"sort": [ | |
{ | |
"_score": { | |
"order": "desc" | |
} | |
} | |
] | |
}' | |
curl -XPOST 'http://localhost:9200/properties/_search?pretty=true' -d ' | |
{ | |
"from": 0, | |
"size": 10, | |
"query": { | |
"bool": { | |
"must": [ | |
{ | |
"has_parent": { | |
"query": { | |
"bool": { | |
"must": { | |
"match": { | |
"address": { | |
"query": "123 Fake St", | |
"type": "boolean" | |
} | |
} | |
} | |
} | |
}, | |
"parent_type": "property", | |
"score_type": "score" | |
} | |
} | |
], | |
"should": [ | |
{ | |
"match": { | |
"fullName": { | |
"query": "Bob Jones", | |
"type": "boolean" | |
} | |
} | |
} | |
], | |
"minimum_should_match": "1" | |
} | |
}, | |
"sort": [ | |
{ | |
"_score": { | |
"order": "desc" | |
} | |
} | |
] | |
}' | |
curl -XPOST 'http://localhost:9200/properties/_search?pretty=true' -d ' | |
{ | |
"from": 0, | |
"size": 10, | |
"query": { | |
"bool": { | |
"must": [ | |
{ | |
"has_parent": { | |
"query": { | |
"bool": { | |
"must": { | |
"match": { | |
"address": { | |
"query": "123 Fake St", | |
"type": "boolean" | |
} | |
} | |
} | |
} | |
}, | |
"parent_type": "property" | |
} | |
} | |
], | |
"should": [ | |
{ | |
"match": { | |
"fullName": { | |
"query": "Bob Jones", | |
"type": "boolean" | |
} | |
} | |
} | |
], | |
"minimum_should_match": "1" | |
} | |
}, | |
"sort": [ | |
{ | |
"_score": { | |
"order": "desc" | |
} | |
} | |
] | |
}' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment