SOLVED
Sorry for anyone still viewing. Please disregard! The original question is left beneath. The issue is that the post request was being run via Postman, which had a bug that modified our query in an unexpected way. Using curl solved the issue.
I've got a development cluster running locally on port 9299. I've added a single item (a comment thread), such that I see the following when visiting http://localhost:9299/comment_threads/_search?pretty=true&q=*&size=10000
{
"took" : 2,
"timed_out" : false,
"_shards" : {
"total" : 3,
"successful" : 3,
"skipped" : 0,
"failed" : 0
},
"hits" : {
"total" : 1,
"max_score" : 1.0,
"hits" : [
{
"_index" : "comment_threads",
"_type" : "comment_thread",
"_id" : "1",
"_score" : 1.0,
"_source" : {
"title" : "Test Title 1",
"category" : null,
"title_textp" : "Test Title 1",
"updated_at" : 1522872115,
"deleted" : false,
"created_at" : 1522872115,
"replies" : 0,
"replies_boost" : 1,
"country" : null,
"state" : null,
"location" : {
"lat" : 13.37,
"lon" : -31.14
}
}
}
]
}
}
I'm running Elasticsearch via the following command with Docker:
docker run --name elasticsearch-test --rm -d -p 9299:9200 -p 9399:9300 -e "discovery.type=single-node" docker.elastic.co/elasticsearch/elasticsearch:6.0.0
My mappings (as given by http://localhost:9299/comment_threads/_mappings?pretty) are here:
{
"comment_threads" : {
"mappings" : {
"comment_thread" : {
"properties" : {
"category" : {
"type" : "keyword"
},
"country" : {
"type" : "keyword"
},
"created_at" : {
"type" : "integer"
},
"deleted" : {
"type" : "boolean"
},
"location" : {
"type" : "geo_point"
},
"replies" : {
"type" : "integer"
},
"replies_boost" : {
"type" : "float"
},
"state" : {
"type" : "keyword"
},
"title" : {
"type" : "text",
"analyzer" : "standard"
},
"title_textp" : {
"type" : "text",
"boost" : 2.0,
"analyzer" : "standard"
},
"updated_at" : {
"type" : "integer"
}
}
}
}
}
}
And I'm sending a request as follows:
POST http://localhost:9299/comments_threads/search?pretty
{
"query":{
"function_score":{
"query":{
"bool":{
"filter":[
{
"bool":{
"must":[
{
"geo_distance":{
"location":{
"lat":13.37,
"lon":-31.14
},
"distance":"50km"
}
},
{
"term":{
"deleted":false
}
}
]
}
}
]
}
}
}
},
"size":1,
"from":0,
"track_scores":true
}
My response is
{
"_index": "comments_threads",
"_type": "search",
"_id": "EC5RkmIBaoZ4KJmilJRz",
"_version": 1,
"result": "created",
"_shards": {
"total": 2,
"successful": 1,
"failed": 0
},
"_seq_no": 0,
"_primary_term": 1
}
I feel almost certain that something is wrong with my environment set-up, as a coworker has been running the same commands in the same circumstances (insofar as I can tell) and getting the desired response (the single comment_thread record). If anyone has ideas about what I could investigate to see why I'm not getting any response, please let me know.
Thank you!