blob: 81b948682df21e057f8973efe61948c5a7a17742 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.prelude.searcher;
import com.yahoo.search.result.Hit;
import com.yahoo.search.result.Relevance;
import com.yahoo.search.Query;
import com.yahoo.search.Result;
import com.yahoo.search.Searcher;
import com.yahoo.search.searchchain.Execution;
/**
* Save the query in the incoming state to a meta hit in the result.
*
* @author <a href="mailto:steinar@yahoo-inc.com">Steinar Knutsen</a>
*/
public class QuerySnapshotSearcher extends Searcher {
public Result search(Query query, Execution execution) {
Query q = query.clone();
Result r = execution.search(query);
Hit h = new Hit("meta:querysnapshot", new Relevance(
Double.POSITIVE_INFINITY));
h.setMeta(true);
h.setField("query", q);
r.hits().add(h);
return r;
}
}
|