Skip to content

Commit

Permalink
seems like a right thing
Browse files Browse the repository at this point in the history
  • Loading branch information
mkhludnev committed Dec 7, 2024
1 parent 49ddee4 commit 39dadf2
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import static org.apache.solr.handler.RequestHandlerBase.isInternalShardRequest;

/**
* User Behavior Insights (UBI) is an open standard for gathering query and event data from users
* and storing it in a structured format. UBI can be used for in session personalization, implicit
Expand Down Expand Up @@ -231,8 +233,9 @@ public void process(ResponseBuilder rb) throws IOException {
if (!params.getBool(COMPONENT_NAME, false)) {
return;
}

doStuff(rb);
if (!isInternalShardRequest(rb.req)) { // subordinate shard req shouldn't yield logs
doStuff(rb);
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
<schema name="ubi_enabled" version="1.1">
<field name="id" type="string" indexed="true" stored="true"/>
<fieldType name="string" class="solr.StrField"/>
<dynamicField name="*" type="string" indexed="true" stored="true"/>
<fieldType name="text" class="solr.TextField"/>
<fieldType name="long" class="${solr.tests.LongFieldType}" docValues="${solr.tests.numeric.dv}" precisionStep="0" omitNorms="true" positionIncrementGap="0" uninvertible="true"/>
<!-- suppress __root__nes dynamicField name="*" type="string" indexed="true" stored="true"/-->
<field name="subject" type="text" indexed="true" stored="true"/>
<field name="_version_" type="long" indexed="true" stored="true"/>
<uniqueKey>id</uniqueKey>
</schema>
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,13 @@ public void cleanIndex() throws Exception {
@Test
public void testUBIQueryStream() throws Exception {
cluster.getSolrClient(COLLECTIONORALIAS).add(List.of(new SolrInputDocument("id", "1", "subject", "aa"),
new SolrInputDocument("id", "two", "subject", "aa"),
new SolrInputDocument("id", "2" /*"two"*/, "subject", "aa"),
new SolrInputDocument("id", "3", "subject", "aa")));
cluster.getSolrClient(COLLECTIONORALIAS).commit(true, true);
QueryResponse queryResponse = cluster.getSolrClient(COLLECTIONORALIAS).query(new MapSolrParams(Map.of("q", "aa", "rows", "2", "ubi", "true")));
System.out.println(queryResponse);
QueryResponse queryResponse = cluster.getSolrClient(COLLECTIONORALIAS).query(new MapSolrParams(
Map.of("q", "aa", "df","subject", "rows", "2", "ubi", "true"
)));
System.out.println(queryResponse.getResponse().get("ubi"));
// TODO check that ids were recorded
}
}

0 comments on commit 39dadf2

Please sign in to comment.