Search type in custom score queries


(John Chang) #1

I am doing some normal custom queries through the java api, and some custom score queries through the java api.

My non scored queries used SearchType DFS_QUERY_THEN_FETCH. However, I see in the unit test org.elasticsearch.test.integration.search.customscore.CustomScoreSearchTests that the SearchType is QUERY_THEN_FETCH.

A few questions:

  1. Is QUERY_THEN_FETCH the preferred (or mandatory) search type for custom score queries?
  2. Either way, I'm getting failures if I do custom score queries (although they worked before, not sure why I have the problems now). If I do a custom score query with DFS_QUERY_THEN_FETCH, I get no results back. If I do QUERY_THEN_FETCH, the the client gets this CLIENT EXCEPTION below, and the server prints the SERVER ERROR below. When I do the exact same query but without custom scoring (using DFS_QUERY_THEN_FETCH) I get the correct results back.

CLIENT EXCEPTION: (when doing custom score with QUERY_THEN_FETCH)
org.elasticsearch.action.search.SearchPhaseExecutionException: Failed to execute phase [query], total failure; shardFailures {[3ccbea0e-b8d6-4440-af3a-71761b3eabfa][index0][1]: RemoteTransportException[[Thena][inet[/10.3.3.156:9300]][search/phase/query]]; nested: QueryPhaseExecutionException[[index0][1]: query[custom score .(+userId:34c40bec15234b4abb900413d464c68b +(body:subject* subject:subject* to:subject* from:subject* cc:subject*),function=org.elasticsearch.index.query.xcontent.CustomScoreQueryParser$ScriptScoreFunction@113ee167)],from[0],size[1000]: Query Failed [Failed to execute main query]];....

SERVER ERROR: (when doing custom score with QUERY_THEN_FETCH)
[12:03:31,942][INFO ][cluster.service ] [Thena] removed {[Balder][292c279e-cae2-435a-a94e-85f9fd6dadf0][inet[/10.3.3.156:9302]]{client=true, data=false, zen.master=false},}, reason: zen-disco-node_failed([Balder][292c279e-cae2-435a-a94e-85f9fd6dadf0][inet[/10.3.3.156:9302]]{client=true, data=false, zen.master=false}), reason transport disconnected


(John Chang) #2

I should add that when I do the QUERY_THEN_FETCH and get the error server-side reading 'transport disconnected', I can still go back with the same client instance and index more documents without any reconnect steps.


(John Chang) #3

Please ignore the stuff about the "SERVER ERROR" above. That has nothing to do with it; it was just the normal message logged on the server when my test is done and goes out of scope. It happens even on the successful non-sorted queries when the test client vm goes away. Sorry. However, I still do believe the client-side exception is a problem.


(John Chang) #4

I fixed the exception - I had mapped the field I wanted to sort on as a string and not a float. Sorry. But still, if you could comment on the preferred QueryType for sorted searches, I'd appreciate it.


(Shay Banon) #5

The preferred type is QUERY_THEN_FETCH, thats why its the default ;). if you
want exact scoring, then you can use DFS one (assuming the distribution of
terms is really different between shards).

-shay.banon

On Thu, Aug 19, 2010 at 11:42 PM, John Chang jchangkihtest2@gmail.comwrote:

I fixed the exception - I had mapped the field I wanted to sort on as a
string and not a float. Sorry. But still, if you could comment on the
preferred QueryType for sorted searches, I'd appreciate it.

View this message in context:
http://elasticsearch-users.115913.n3.nabble.com/Search-type-in-custom-score-queries-tp1230940p1232662.html
Sent from the ElasticSearch Users mailing list archive at Nabble.com.


(system) #6