use of org.apache.solr.client.solrj.SolrQuery in project lucene-solr by apache.
the class TestExternalFeatures method featureExtraction_valueFeatureImplicitlyNotRequired_shouldNotScoreFeature.
@Test
public void featureExtraction_valueFeatureImplicitlyNotRequired_shouldNotScoreFeature() throws Exception {
final SolrQuery query = new SolrQuery();
query.setQuery("*:*");
query.add("rows", "1");
final String docs0fvalias_dense_csv = FeatureLoggerTestUtils.toFeatureVector("occurrences", "0.0", "originalScore", "0.0");
final String docs0fvalias_sparse_csv = FeatureLoggerTestUtils.toFeatureVector("originalScore", "0.0");
final String docs0fvalias_default_csv = chooseDefaultFeatureVector(docs0fvalias_dense_csv, docs0fvalias_sparse_csv);
// Efi is explicitly not required, so we do not score the feature
query.remove("fl");
query.add("fl", "fvalias:[fv store=fstore3]");
assertJQ("/query" + query.toQueryString(), "/response/docs/[0]/fvalias=='" + docs0fvalias_default_csv + "'");
}
use of org.apache.solr.client.solrj.SolrQuery in project lucene-solr by apache.
the class TestExternalFeatures method testEfiInTransformerShouldNotChangeOrderOfRerankedResults.
@Test
public void testEfiInTransformerShouldNotChangeOrderOfRerankedResults() throws Exception {
final SolrQuery query = new SolrQuery();
query.setQuery("*:*");
query.add("fl", "*,score");
query.add("rows", "3");
// Regular scores
assertJQ("/query" + query.toQueryString(), "/response/docs/[0]/id=='1'");
assertJQ("/query" + query.toQueryString(), "/response/docs/[0]/score==1.0");
assertJQ("/query" + query.toQueryString(), "/response/docs/[1]/id=='2'");
assertJQ("/query" + query.toQueryString(), "/response/docs/[1]/score==1.0");
assertJQ("/query" + query.toQueryString(), "/response/docs/[2]/id=='3'");
assertJQ("/query" + query.toQueryString(), "/response/docs/[2]/score==1.0");
query.remove("fl");
query.add("fl", "*,score,[fv]");
query.add("rq", "{!ltr reRankDocs=10 model=externalmodel efi.user_query=w3 efi.userTitlePhrase1=w4 efi.userTitlePhrase2=w5}");
assertJQ("/query" + query.toQueryString(), "/response/docs/[0]/id=='3'");
assertJQ("/query" + query.toQueryString(), "/response/docs/[0]/score==0.7693934");
assertJQ("/query" + query.toQueryString(), "/response/docs/[1]/score==0.0");
assertJQ("/query" + query.toQueryString(), "/response/docs/[2]/score==0.0");
// Adding an efi in the transformer should not affect the rq ranking with a
// different value for efi of the same parameter
query.remove("fl");
query.add("fl", "*,score,[fv efi.user_query=w2 efi.userTitlePhrase1=w4 efi.userTitlePhrase2=w5]");
assertJQ("/query" + query.toQueryString(), "/response/docs/[0]/id=='3'");
assertJQ("/query" + query.toQueryString(), "/response/docs/[0]/score==0.7693934");
assertJQ("/query" + query.toQueryString(), "/response/docs/[1]/score==0.0");
assertJQ("/query" + query.toQueryString(), "/response/docs/[2]/score==0.0");
}
use of org.apache.solr.client.solrj.SolrQuery in project lucene-solr by apache.
the class TestExternalFeatures method featureExtraction_valueFeatureExplicitlyNotRequired_shouldNotScoreFeature.
@Test
public void featureExtraction_valueFeatureExplicitlyNotRequired_shouldNotScoreFeature() throws Exception {
final SolrQuery query = new SolrQuery();
query.setQuery("*:*");
query.add("rows", "1");
final String docs0fvalias_dense_csv = FeatureLoggerTestUtils.toFeatureVector("occurrences", "0.0", "originalScore", "0.0");
final String docs0fvalias_sparse_csv = FeatureLoggerTestUtils.toFeatureVector("originalScore", "0.0");
final String docs0fvalias_default_csv = chooseDefaultFeatureVector(docs0fvalias_dense_csv, docs0fvalias_sparse_csv);
// Efi is explicitly not required, so we do not score the feature
query.remove("fl");
query.add("fl", "fvalias:[fv store=fstore3]");
assertJQ("/query" + query.toQueryString(), "/response/docs/[0]/fvalias=='" + docs0fvalias_default_csv + "'");
}
use of org.apache.solr.client.solrj.SolrQuery in project lucene-solr by apache.
the class TestExternalFeatures method featureExtraction_valueFeatureRequired_shouldThrowException.
@Test
public void featureExtraction_valueFeatureRequired_shouldThrowException() throws Exception {
final SolrQuery query = new SolrQuery();
query.setQuery("*:*");
query.add("rows", "1");
// Using nondefault store should still result in error with no efi when it is required (myPop)
query.remove("fl");
query.add("fl", "fvalias:[fv store=fstore4]");
assertJQ("/query" + query.toQueryString(), "/error/msg=='Exception from createWeight for ValueFeature [name=popularity, params={value=${myPop}, required=true}] ValueFeatureWeight requires efi parameter that was not passed in request.'");
}
use of org.apache.solr.client.solrj.SolrQuery in project lucene-solr by apache.
the class TestExternalValueFeatures method efiFeatureProcessing_oneEfiMissing_shouldNotCalculateMissingFeature.
@Test
public void efiFeatureProcessing_oneEfiMissing_shouldNotCalculateMissingFeature() throws Exception {
SolrQuery query = new SolrQuery();
query.setQuery("*:*");
query.add("fl", "*,score,features:[fv]");
query.add("rows", "3");
query.add("rq", "{!ltr reRankDocs=3 model=external_model_binary_feature efi.user_device_tablet=1}");
final String docs0features_dense_csv = FeatureLoggerTestUtils.toFeatureVector("user_device_smartphone", "0.0", "user_device_tablet", "1.0");
final String docs0features_sparse_csv = FeatureLoggerTestUtils.toFeatureVector("user_device_tablet", "1.0");
final String docs0features_default_csv = chooseDefaultFeatureVector(docs0features_dense_csv, docs0features_sparse_csv);
assertJQ("/query" + query.toQueryString(), "/response/docs/[0]/id=='1'");
assertJQ("/query" + query.toQueryString(), "/response/docs/[0]/features=='" + docs0features_default_csv + "'");
assertJQ("/query" + query.toQueryString(), "/response/docs/[0]/score==65.0");
}
Aggregations