Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

URI search not returning results when &fields used #10490

Closed
tnesavich opened this issue Apr 8, 2015 · 3 comments
Closed

URI search not returning results when &fields used #10490

tnesavich opened this issue Apr 8, 2015 · 3 comments
Labels
:Analytics/Geo Indexing, search aggregations of geo points and shapes discuss

Comments

@tnesavich
Copy link

Running into an issue with URI searches not returning expected results after upgrading from 0.90.9 to 1.4.1

The issue is that subfields are not returned when specified with "&fields". I have confirmed that the data is there by doing the same search without the &fields specifications and get the Meter.geometry.coordinates. I am not seeing anything in the release notes for 1.4.1 that indicate any change in URI search functionality.

Hoping someone has run into this already and can tell me how to specify subfields for results sets other than the &fields method or how to get the &fields method to work again in 1.4.1+

Thanks in advance.

0.90.9 URI Search:
https://contoso.com/customer/v1/tapsandmeters?q=Meter.servicePointId:0865540026&fields=Meter.geometry.coordinates

0.90.9 URI Search Results:
{
took: 2,
timed_out: false,
_shards:
{
total: 3,
successful: 3,
failed: 0
},
hits:
{
total: 1,
max_score: 11.723421,
hits:
[
{
_index: "customer12345",
_type: "TapAndMeter",
_id: "086554009008655400270865540026",
_score: 11.723421,
fields:
{
Meter.geometry.coordinates:
{
lon: -104.959796299,
lat: 39.7702803882
}
}
}
]
}
}

1.4.1 URI Search:
https://newercontoso.comcustomer/v1/tapsandmeters?q=Meter.servicePointId:0865540026&fields=Meter.geometry.coordinates

1.4.1 URI Search Results:
{
took: 5,
timed_out: false,
_shards:
{
total: 3,
successful: 3,
failed: 0
},
hits:
{
total: 1,
max_score: 11.856463,
hits:
[
{
_index: "customer12345",
_type: "TapAndMeter",
_id: "086554009008655400270865540026",
_score: 11.856463
}
]
}
}

@tnesavich
Copy link
Author

Interesting thing to note. ... This issue is only for fields of Geo Point Type (geo_point)
http://www.elastic.co/guide/en/elasticsearch/reference/1.4/mapping-geo-point-type.html

Tests of other fields work.

@clintongormley clintongormley added :Analytics/Geo Indexing, search aggregations of geo points and shapes discuss labels Apr 11, 2015
@clintongormley
Copy link
Contributor

Hi @tnesavich

These days we prefer the _source parameter to extract the original values from the _source field, eg:

https://newercontoso.comcustomer/v1/tapsandmeters?q=Meter.servicePointId:0865540026&_source=Meter.geometry.coordinates

If you want to retrieve the actual coordinates, you could set the coordinates field to store:true, in which case it'll return an array of indexed values:

PUT test 
{
  "mappings": {
    "test": {
      "properties": {
        "loc": {
          "type": "geo_point",
          "store": true
        }
      }
    }
  }
}

PUT test/test/1
{
  "loc": {"lat":1, "lon": 2}
}
PUT test/test/2
{
  "loc": [1,2]
}

GET /test/test/_search?fields=loc

returns:

  "hits": [
     {
        "_index": "test",
        "_type": "test",
        "_id": "1",
        "_score": 1,
        "fields": {
           "loc": [
              "1.0,2.0"
           ]
        }
     },
     {
        "_index": "test",
        "_type": "test",
        "_id": "2",
        "_score": 1,
        "fields": {
           "loc": [
              "2.0,1.0"
           ]
        }
     }
  ]

That said, the fields parameter should fall back to extracting the values from the _source field if the field is not stored. Thoughts?

@clintongormley
Copy link
Contributor

The fields parameter no longer falls back to extracting from source. #15017

Closing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Analytics/Geo Indexing, search aggregations of geo points and shapes discuss
Projects
None yet
Development

No branches or pull requests

2 participants