blob: fb8e76f36ec16943510457cebb4b5c23e01d01c0 (
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
30
|
package com.mydomain.example;
import com.yahoo.search.Query;
import com.yahoo.search.Result;
import com.yahoo.search.Searcher;
import com.yahoo.search.result.Hit;
import com.yahoo.search.searchchain.Execution;
/**
* A searcher adding a new hit.
*
* @author Joe Developer
*/
public class ExampleSearcher extends Searcher {
public static final String hitId = "ExampleHit";
private final String message;
public ExampleSearcher(MessageConfig config) {
message = config.message();
}
public Result search(Query query, Execution execution) {
Hit hit = new Hit(hitId);
hit.setField("message", message);
Result result = execution.search(query);
result.hits().add(hit);
return result;
}
}
|