From c3dfe8a0f2506701d50cae3ecf90bffea42edb62 Mon Sep 17 00:00:00 2001 From: PeterLombaers <71253799+PeterLombaers@users.noreply.github.com> Date: Thu, 28 Mar 2024 10:36:23 +0100 Subject: [PATCH] Update searcher-development.html Update the example of writing a searcher to make use of the Vespa dataclasses. --- en/searcher-development.html | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/en/searcher-development.html b/en/searcher-development.html index e31efdd04b..825d5fcc2d 100644 --- a/en/searcher-development.html +++ b/en/searcher-development.html @@ -165,6 +165,7 @@
{% highlight java %} package com.yahoo.search.example; +import com.yahoo.data.access.simple.Value; import com.yahoo.search.*; import com.yahoo.search.result.Hit; import com.yahoo.search.searchchain.Execution; @@ -178,6 +179,9 @@Writing a Searcher
Result result = execution.search(query); // Pass on to the next searcher to get results Hit hit = new Hit("test"); hit.setField("message", "Hello world"); + Value.ObjectValue mapValue = new Value.ObjectValue(); // For structured data, use the dedicated class + mapValue.put("hello", "world"); + hit.setField("mapValue", mapValue); result.hits().add(hit); return result; }