Suddenly I can't sort on a field in an empty set, ignore_unmapped not helping


(doug livesey) #1

Hi -- I've had a test suite running just fine for ages, in which a number
of searches are performed, and return sorted on a listed_at field.
I've had to monkey around with some stuff due to Typhoeus changing how it
handles GET requests (most annoyingly), but the only changes to the queries
I'm running is that they are POSTs rather than GETs, now. The queries have
remained the same.
However, I've now got them all failing with 500s when there are no items to
search on in the index. This never used to happen, I don't think.
Anyway, I looked at the documentation again, and saw the bit about
ignore_unmapped, and thought I'd try that -- but I still get a failure that
complains about the field I'm trying to sort on.

An example query looks like this:
curl -XPOST "http://localhost:9200/my_test_search/items/_search" -d
"{"from":0,"size":60,"sort":{"listed_at":{"order":"desc","ignore_unmapped":true}},"query":{"term":{"category_id":1}}}"

And I get this from the body of the 500 response:
Parse Failure [Failed to parse source
[{"from":0,"size":60,"sort":{"listed_at":{"order":"desc","ignore_unmapped":true}},"query":{"term":{"category_id":1}}}]]];
nested: SearchParseException[[my_test_search][6]: from[0],size[60]: Parse
Failure [No mapping found for [listed_at] in order to sort on]];
}]","status":500

Could anyone advise me as to what I could look into next? I'm totally
stumped.
Cheers,
Doug.

--


(doug livesey) #2

Hi -- updating ES fixed my first issue with this, however I now have a
similar issue with a faceted search. Unfortunately, it doesn't seem to
accept "ignore_unmapped", and explicitly creating the mappings on the index
doesn't seem to help, either.
I created the index and the mappings like this:

curl -XPOST "http://localhost:9200/my_test_search"
-d "{"mappings":{"items":{"properties":{"listed_at":{"type":"date"},"price":{"type":"float"},"colour_ids":{"index_name":"colour_id","type":"integer"},"material_ids":{"index_name":"material_id","type":"integer"}}}},"replicas":1}"

To my mind, this should have created the mapping "price" on the items type,
but apparently not, as running this query:

curl -XPOST "
http://localhost:9200/my_test_search/items/_search?pretty=true" -d
"{"facets":{"facet":{"range":{"field":"price","ranges":[{"to":4.991,"from":0.0},{"to":15.001,"from":5.0},{"to":25.001,"from":15.01},{"to":50.001,"from":25.01},{"to":75.001,"from":50.01},{"to":100.001,"from":75.01},{"from":100.01}],"size":250}}},"size":0,"query":{"term":{"category_id":1}}}"

Gives me a 500 with this at the end of the voluminous error output:

nested: FacetPhaseExecutionException[Facet [facet]: No mapping found for
key_field [price]];

I don't know why this issue suddenly raised it's head, but it's broken all
my tests, and I'm looking, now, at the
employee/employer-relationship-straining task of having to rewrite all our
search code to handle the failures caused by it.
Can anyone offer any advice at all?
Cheers,
Doug.

--


(doug livesey) #3

Got it! (Kind of).
So, I had a query deleting all items before the tests ran, like this:
put -XDELETE "http://localhost:9200/folksy_test_search/items?q=match_all"

It looks like that was deleting the mappings, too, so I guess I've got the
match_all bit of that query wrong?
It used to send a delete with the query in the body, and that worked
fine, but I recently updated Typoheus (the old version was being flakey),
and unfortunately Typhoeus now makes any request with a body into a POST,
whether you want it to or not (I emphatically don't!).
So I guess my question now is, how can I delete the items in the index
without deleting the mappings?
I'll look into it, later, but in the meantime, this all gives me enough to
create a work-around that'll let me crack on with other stuff.
Every day's a schoolday! :slight_smile:
Cheers,
Doug.

--


(David Pilato) #4

Have a look at this:
http://www.elasticsearch.org/guide/reference/api/delete-by-query.html
http://www.elasticsearch.org/guide/reference/api/delete-by-query.html

You didn't use _query endpoint so ES thought you were asking to delete the type
items
(http://www.elasticsearch.org/guide/reference/api/admin-indices-delete-mapping.html
http://www.elasticsearch.org/guide/reference/api/admin-indices-delete-mapping.html
).

HTH
David.

Le 31 août 2012 à 12:13, doug livesey biot023@gmail.com a écrit :

Got it! (Kind of).
So, I had a query deleting all items before the tests ran, like this:
put -XDELETE " http://localhost:9200/folksy_test_search/items?q=match_all
http://localhost:9200/folksy_test_search/items?q=match_all "

It looks like that was deleting the mappings, too, so I guess I've got the
match_all bit of that query wrong?
It used to send a delete with the query in the body, and that worked fine,
but I recently updated Typoheus (the old version was being flakey), and
unfortunately Typhoeus now makes any request with a body into a POST, whether
you want it to or not (I emphatically don't!).
So I guess my question now is, how can I delete the items in the index
without deleting the mappings?
I'll look into it, later, but in the meantime, this all gives me enough to
create a work-around that'll let me crack on with other stuff.
Every day's a schoolday! :slight_smile:
Cheers,
Doug.

--

--
David Pilato
http://www.scrutmydocs.org/
http://dev.david.pilato.fr/
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

--


(doug livesey) #5

Ah, cheers -- I shall have a play around with that.

On 31 August 2012 14:37, David Pilato david@pilato.fr wrote:

**

Have a look at this:
http://www.elasticsearch.org/guide/reference/api/delete-by-query.html

You didn't use _query endpoint so ES thought you were asking to delete the
type items (
http://www.elasticsearch.org/guide/reference/api/admin-indices-delete-mapping.html
).

HTH

David.

Le 31 août 2012 à 12:13, doug livesey biot023@gmail.com a écrit :

Got it! (Kind of).
So, I had a query deleting all items before the tests ran, like this:
put -XDELETE "
http://localhost:9200/folksy_test_search/items?q=match_all"

It looks like that was deleting the mappings, too, so I guess I've got
the match_all bit of that query wrong?
It used to send a delete with the query in the body, and that worked
fine, but I recently updated Typoheus (the old version was being flakey),
and unfortunately Typhoeus now makes any request with a body into a POST,
whether you want it to or not (I emphatically don't!).
So I guess my question now is, how can I delete the items in the index
without deleting the mappings?
I'll look into it, later, but in the meantime, this all gives me enough
to create a work-around that'll let me crack on with other stuff.
Every day's a schoolday! :slight_smile:
Cheers,
Doug.

--

--
David Pilato
http://www.scrutmydocs.org/
http://dev.david.pilato.fr/
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

--

--


(system) #6