Skip to content

Commit

Permalink
now it checks that query were recorded. Not sure about doc ids.
Browse files Browse the repository at this point in the history
  • Loading branch information
mkhludnev committed Dec 8, 2024
1 parent 39dadf2 commit 995a0cf
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -121,5 +121,6 @@ public void initializeMetrics(SolrMetricsContext parentContext, String scope) {
Map.entry(RealTimeGetComponent.COMPONENT_NAME, RealTimeGetComponent.class),
Map.entry(ExpandComponent.COMPONENT_NAME, ExpandComponent.class),
Map.entry(TermsComponent.COMPONENT_NAME, TermsComponent.class),
Map.entry(UBIComponent.COMPONENT_NAME, UBIComponent.class));
Map.entry(UBIComponent.COMPONENT_NAME, UBIComponent.class)// oh r'lly?? esp giving that it receive some expr via init args
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ public class SearchHandler extends RequestHandlerBase
protected List<String> getDefaultComponents() {
List<String> l = new ArrayList<String>(SearchComponent.STANDARD_COMPONENTS.keySet());
moveToFirst(l, QueryComponent.COMPONENT_NAME);
l.remove(RealTimeGetComponent.COMPONENT_NAME); // pardon. it breaks my essential cloud test. there wasn't it there ever!
return l;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@
<schema name="ubi_enabled" version="1.1">
<field name="id" type="string" indexed="true" stored="true"/>
<fieldType name="string" class="solr.StrField"/>
<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"/>
<dynamicField name="*" type="string" indexed="true" stored="true"/>
<uniqueKey>id</uniqueKey>
</schema>
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import org.apache.solr.client.solrj.response.QueryResponse;
import org.apache.solr.cloud.AbstractDistribZkTestBase;
import org.apache.solr.cloud.SolrCloudTestCase;
import org.apache.solr.cluster.api.SimpleMap;
import org.apache.solr.common.SolrInputDocument;
import org.apache.solr.common.params.MapSolrParams;
import org.apache.solr.common.params.SolrParams;
Expand Down Expand Up @@ -63,7 +64,7 @@ public static void setupCluster() throws Exception {
.configure();

String collection;
useAlias = random().nextBoolean();
useAlias = false; //random().nextBoolean();
if (useAlias) {
collection = COLLECTIONORALIAS + "_collection";
} else {
Expand All @@ -84,7 +85,8 @@ public static void setupCluster() throws Exception {

// -------------------

CollectionAdminRequest.createCollection("ubi_queries", "_default", 1, 1)
CollectionAdminRequest.createCollection("ubi_queries",// it seems like a hardcoded name why?
"_default", 1, 1)
.process(cluster.getSolrClient());

cluster.waitForActiveCollection("ubi_queries", 1, 1);
Expand All @@ -107,7 +109,15 @@ public void testUBIQueryStream() throws Exception {
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"));
String qid = (String) ((SimpleMap<?>) queryResponse.getResponse().get("ubi")).get("query_id");
assertTrue(qid.length()>10);
Thread.sleep(10000); // I know what you think of
// TODO check that ids were recorded
QueryResponse queryCheck = cluster.getSolrClient("ubi_queries").query(new MapSolrParams(
Map.of("q", "id:"+qid //doesn't search it why? is it a race?
)));
// however I can't see doc ids found there. Shouldn't I ?
assertEquals(1L, queryCheck.getResults().getNumFound());
assertEquals(queryCheck.getResults().get(0).get("id"),qid);
}
}

0 comments on commit 995a0cf

Please sign in to comment.