Custom fields for each type


(Wojtas) #1

Hi,

is it possible to return different source fields for different document types?
or query different fields for different types?

I would like to do something like this but in one request:

curl -XGET 'http://localhost:9200/my-index/MYTYPE1/_search?pretty' -d '{
"_source": [ "MYTYPE1.field1" ],
"min_score": 1,
"query": {
"bool" : {
"must" : {
"query_string" : {
"fields" : ["MYTYPE1.field1"],
"query" : "queryString~*"
}
}
}
}
}
'

curl -XGET 'http://localhost:9200/my-index/MYTYPE2/_search?pretty' -d '{
"_source": [ "MYTYPE2.field1", "MYTYPE2.field2" ],
"min_score": 1,
"query": {
"bool" : {
"must" : {
"query_string" : {
"fields" : ["MYTYPE2.field2"],
"query" : "queryString~*"
}
}
}
}
}
'

Regards, Wojtas


(Mark Walkom) #2

I don't believe you can, no.


(Colin Goodheart-Smithe) #3

You could use the multi search API to do this in one request. It would still be running separate searches on the elasticsearch cluster so you would still get 10 hits per type but you would get the results in a single response. This is probably the closest to what you want that is possible currently


(system) #4