-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Description
Hi,
I'm trying to search with the following query:
sd.Query(q => q .MoreLikeThis(mlt => mlt .Fields(fs => fs .Field(f => f.DocumentTitle) .Field(f => f.DocumentType) .Field(f => f.Years) .Field(f => f.Brand)) .Like(l => l .Document(d => d .Document(new DocumentSearchModel() { DocumentTitle = title, Brand = brand, Years = years, DocumentType = type }))) .MinTermFrequency(1) .MaxDocumentFrequency(3)));
But ES responses, that this query is invalid, because I can either search for id or doc, but not both. Exception:
Elasticsearch.Net.ElasticsearchClientException: Request failed to execute. Call: Status code 400 from: POST /documents/documentsearchmodel/_search?typed_keys=true. ServerError: Type: parse_exception Reason: "failed to parse More Like This item. either [id] or [doc] can be specified, but not both!"
Request:
{"query":{"more_like_this":{"fields":["documentTitle","documentType","years","brand"],"like":[{"doc":{"documentID":0,"documentType":"Prospekt","documentTitle":"Dürkopp Prospekt 1940er Jahre","brand":"Dürkopp","years":[1947,1948,1949,1950],"pages":0,"vagueMatch":false,"createdAt":"0001-01-01T00:00:00"},"_id":"0","_index":"documents","_type":"documentsearchmodel"}],"max_doc_freq":3,"min_term_freq":1}}}
Response:
{"error":{"root_cause":[{"type":"parse_exception","reason":"failed to parse More Like This item. either [id] or [doc] can be specified, but not both!"}],"type":"parse_exception","reason":"failed to parse More Like This item. either [id] or [doc] can be specified, but not both!"},"status":400}
Inspecting the request one can see, that _id is included with the default value: 0. I think this should not happen. If id is not set, it should not be included in the query.
I've tested this on the latest ES6.x and Nest 6.x versions.