Skip to content

Instantly share code, notes, and snippets.

@imotov
Created March 20, 2013 10:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save imotov/5203687 to your computer and use it in GitHub Desktop.
Save imotov/5203687 to your computer and use it in GitHub Desktop.
curl -XDELETE localhost:9200/users
curl -XPUT localhost:9200/users -d '{
"settings": {
"index.number_of_shards": 1,
"index.number_of_replicas": 0
},
"mappings": {
"user": {
"properties": {
"affiliate_program_id": {
"type": "long"
},
"affiliate_state_id": {
"type": "long"
},
"apps_events": {
"type": "nested",
"dynamic": "true",
"properties": {
"affiliate_program_id": {
"type": "long"
},
"frequency": {
"type": "string"
},
"id": {
"type": "long"
},
"locations": {
"type": "nested",
"dynamic": "true",
"properties": {
"inf": {
"type": "long"
},
"location_id": {
"type": "long"
},
"sup": {
"type": "long"
}
}
},
"price_max": {
"type": "string"
},
"price_min": {
"type": "string"
},
"property_classes": {
"type": "string"
},
"source": {
"type": "string"
},
"status": {
"type": "string"
},
"type": {
"type": "string"
},
"user_id": {
"type": "long"
}
}
},
"email": {
"type": "string"
},
"status": {
"type": "string"
}
}
}
}
}
'
curl -XPOST localhost:9200/users/user/21578 -d '{
"_id": 21578,
"email": "x...@gmail.com",
"affiliate_program_id": 1,
"affiliate_state_id": 1,
"status": "no_verify",
"apps_events": [{
"id": 159026,
"source": "bien_similaire",
"frequency": "real_time",
"status": "active",
"type": "rent",
"user_id": 21578,
"affiliate_program_id": 1,
"locations": [{
"location_id": 7521,
"inf": 17198,
"sup": 17213
}, {
"location_id": 49364,
"inf": 98942,
"sup": 98943
}],
"property_classes": ["appartment", "house", "appartment", "various"],
"price_min": "0",
"price_max": "1000"
}, {
"id": 99662,
"source": "bien_similaire",
"frequency": "real_time",
"status": "inactive",
"type": "rent",
"user_id": 21578,
"affiliate_program_id": 1,
"locations": [{
"location_id": 7540,
"inf": 17138,
"sup": 17145
}, {
"location_id": 7647,
"inf": 17136,
"sup": 17137
}],
"property_classes": ["appartment", "house", "appartment", "various"]
}]
}
'
curl -X POST 'http://localhost:9200/users/_refresh'
curl -X GET 'http://localhost:9200/users/user/_search?from=0&load=&size=20&pretty' -d '{
"query": {
"filtered": {
"query": {
"match_all": {}
},
"filter": {
"and": [{
"nested": {
"path": "apps_events",
"query": {
"filtered": {
"query": {
"match_all": {}
},
"filter": {
"and": [{
"term": {
"apps_events.status": "active"
}
}, {
"or": [{
"nested": {
"path": "apps_events.locations",
"filter": {
"and": [{
"range": {
"apps_events.locations.inf": {
"gte": 59850
}
}
}, {
"range": {
"apps_events.locations.sup": {
"lte": 59851
}
}
}]
}
}
}]
}]
}
}
}
}
}]
}
}
},
"size": 20,
"from": 0
}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment