I'm seeing different results from Model.search and SearchKick.search with a index_name.
I'm trying to apply apply a cross_fields query to multiple indexes. I got some strange results so I started sanity checking the query against a single index and in that scenario I'm getting sero results returned despite the searchkick query object being identical as far as I can tell
cross_field_query = {
body: {
query: {
multi_match: {
query: query,
type: "cross_fields",
operator: "and"
}
}
}
}
results = TaggedTree.search cross_field_query
results.total_count -> 29
results = Searchkick.search cross_field_query, index_name: [TaggedTree]
results.total_count -> 0
I ran the queries with execute: false and they seemed to be the same. Here are the to_curl outputs
results = TaggedTree.search advanced_query, execute: false
results.to_curl
"curl http://localhost:9200/tagged_trees_development/_search?pretty -H 'Content-Type: application/json' -d '{\"query\":{\"dis_max\":{\"queries\":[{\"multi_match\":{\"query\":\"{:body=\\u003e{:query=\\u003e{:multi_match=\\u003e{:query=\\u003e\\\"oak malahide\\\", :type=\\u003e\\\"cross_fields\\\", :operator=\\u003e\\\"and\\\"}}}}\",\"boost\":10,\"operator\":\"and\",\"analyzer\":\"searchkick_search\",\"fields\":[\"*.analyzed\"],\"type\":\"best_fields\"}},{\"multi_match\":{\"query\":\"{:body=\\u003e{:query=\\u003e{:multi_match=\\u003e{:query=\\u003e\\\"oak malahide\\\", :type=\\u003e\\\"cross_fields\\\", :operator=\\u003e\\\"and\\\"}}}}\",\"boost\":10,\"operator\":\"and\",\"analyzer\":\"searchkick_search2\",\"fields\":[\"*.analyzed\"],\"type\":\"best_fields\"}},{\"multi_match\":{\"query\":\"{:body=\\u003e{:query=\\u003e{:multi_match=\\u003e{:query=\\u003e\\\"oak malahide\\\", :type=\\u003e\\\"cross_fields\\\", :operator=\\u003e\\\"and\\\"}}}}\",\"boost\":1,\"operator\":\"and\",\"analyzer\":\"searchkick_search\",\"fuzziness\":1,\"prefix_length\":0,\"max_expansions\":3,\"fuzzy_transpositions\":true,\"fields\":[\"*.analyzed\"],\"type\":\"best_fields\"}},{\"multi_match\":{\"query\":\"{:body=\\u003e{:query=\\u003e{:multi_match=\\u003e{:query=\\u003e\\\"oak malahide\\\", :type=\\u003e\\\"cross_fields\\\", :operator=\\u003e\\\"and\\\"}}}}\",\"boost\":1,\"operator\":\"and\",\"analyzer\":\"searchkick_search2\",\"fuzziness\":1,\"prefix_length\":0,\"max_expansions\":3,\"fuzzy_transpositions\":true,\"fields\":[\"*.analyzed\"],\"type\":\"best_fields\"}}]}},\"timeout\":\"11s\",\"_source\":false,\"size\":10000,\"from\":0}'"
results = Searchkick.search index_advanced_query, index_name: TaggedTree, execute: false
results.to_curl
"curl http://localhost:9200/tagged_trees_development/_search?pretty -H 'Content-Type: application/json' -d '{\"query\":{\"dis_max\":{\"queries\":[{\"multi_match\":{\"query\":\"{:body=\\u003e{:query=\\u003e{:multi_match=\\u003e{:query=\\u003e\\\"oak malahide\\\", :type=\\u003e\\\"cross_fields\\\", :operator=\\u003e\\\"and\\\"}}}}\",\"boost\":10,\"operator\":\"and\",\"analyzer\":\"searchkick_search\",\"fields\":[\"*.analyzed\"],\"type\":\"best_fields\"}},{\"multi_match\":{\"query\":\"{:body=\\u003e{:query=\\u003e{:multi_match=\\u003e{:query=\\u003e\\\"oak malahide\\\", :type=\\u003e\\\"cross_fields\\\", :operator=\\u003e\\\"and\\\"}}}}\",\"boost\":10,\"operator\":\"and\",\"analyzer\":\"searchkick_search2\",\"fields\":[\"*.analyzed\"],\"type\":\"best_fields\"}},{\"multi_match\":{\"query\":\"{:body=\\u003e{:query=\\u003e{:multi_match=\\u003e{:query=\\u003e\\\"oak malahide\\\", :type=\\u003e\\\"cross_fields\\\", :operator=\\u003e\\\"and\\\"}}}}\",\"boost\":1,\"operator\":\"and\",\"analyzer\":\"searchkick_search\",\"fuzziness\":1,\"prefix_length\":0,\"max_expansions\":3,\"fuzzy_transpositions\":true,\"fields\":[\"*.analyzed\"],\"type\":\"best_fields\"}},{\"multi_match\":{\"query\":\"{:body=\\u003e{:query=\\u003e{:multi_match=\\u003e{:query=\\u003e\\\"oak malahide\\\", :type=\\u003e\\\"cross_fields\\\", :operator=\\u003e\\\"and\\\"}}}}\",\"boost\":1,\"operator\":\"and\",\"analyzer\":\"searchkick_search2\",\"fuzziness\":1,\"prefix_length\":0,\"max_expansions\":3,\"fuzzy_transpositions\":true,\"fields\":[\"*.analyzed\"],\"type\":\"best_fields\"}}]}},\"timeout\":\"11s\",\"_source\":false,\"size\":10000,\"from\":0}'"
searchkick version: 3.1.2 Elastic Search Version: Version: 6.5.2, Build: default/tar/9434bed/2018-11-29T23:58:20.891072Z, JVM: 1.8.0_20
Any help at all with getting to the bottom of this would be greatly appreciated