lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alessandrobenedetti <...@git.apache.org>
Subject [GitHub] lucene-solr pull request: SOLR-8542: Integrate Learning to Rank in...
Date Wed, 09 Mar 2016 17:41:24 GMT
Github user alessandrobenedetti commented on a diff in the pull request:

    https://github.com/apache/lucene-solr/pull/4#discussion_r55557481
  
    --- Diff: solr/contrib/ltr/src/java/org/apache/solr/ltr/ranking/ModelQuery.java ---
    @@ -0,0 +1,540 @@
    +package org.apache.solr.ltr.ranking;
    +
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one or more
    + * contributor license agreements.  See the NOTICE file distributed with
    + * this work for additional information regarding copyright ownership.
    + * The ASF licenses this file to You under the Apache License, Version 2.0
    + * (the "License"); you may not use this file except in compliance with
    + * the License.  You may obtain a copy of the License at
    + *
    + *     http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +
    +import java.io.IOException;
    +import java.util.ArrayList;
    +import java.util.Collection;
    +import java.util.HashMap;
    +import java.util.List;
    +import java.util.Map;
    +import java.util.Set;
    +
    +import org.apache.lucene.index.LeafReaderContext;
    +import org.apache.lucene.index.Term;
    +import org.apache.lucene.search.DisiPriorityQueue;
    +import org.apache.lucene.search.DisiWrapper;
    +import org.apache.lucene.search.DisjunctionDISIApproximation;
    +import org.apache.lucene.search.DocIdSetIterator;
    +import org.apache.lucene.search.Explanation;
    +import org.apache.lucene.search.IndexSearcher;
    +import org.apache.lucene.search.Query;
    +import org.apache.lucene.search.Scorer;
    +import org.apache.lucene.search.Weight;
    +import org.apache.lucene.search.Scorer.ChildScorer;
    +import org.apache.solr.ltr.feature.ModelMetadata;
    +import org.apache.solr.ltr.feature.norm.Normalizer;
    +import org.apache.solr.ltr.feature.norm.impl.IdentityNormalizer;
    +import org.apache.solr.ltr.log.FeatureLogger;
    +import org.apache.solr.request.SolrQueryRequest;
    +
    +/**
    + * The ranking query that is run, reranking results using the ModelMetadata
    + * algorithm
    + */
    +public class ModelQuery extends Query {
    +
    +  // contains a description of the model
    +  protected ModelMetadata meta;
    +  // feature logger to output the features.
    +  private FeatureLogger fl = null;
    +  // Map of external parameters, such as query intent, that can be used by
    +  // features
    +  protected Map<String,String> efi;
    +  // Original solr query used to fetch matching documents
    +  protected Query originalQuery;
    +  // Original solr request
    +  protected SolrQueryRequest request;
    +
    +  public ModelQuery(ModelMetadata meta) {
    +    this.meta = meta;
    +  }
    +
    +  public ModelMetadata getMetadata() {
    +    return meta;
    +  }
    +
    +  public void setFeatureLogger(FeatureLogger fl) {
    +    this.fl = fl;
    +  }
    +
    +  public FeatureLogger getFeatureLogger() {
    +    return this.fl;
    +  }
    +
    +  public Collection<Feature> getAllFeatures() {
    +    return meta.getAllFeatures();
    +  }
    +
    +  public void setOriginalQuery(Query mainQuery) {
    +    this.originalQuery = mainQuery;
    +  }
    +
    +  public void setExternalFeatureInfo(Map<String,String> externalFeatureInfo) {
    +    this.efi = externalFeatureInfo;
    +  }
    +
    +  public void setRequest(SolrQueryRequest request) {
    +    this.request = request;
    +  }
    +
    +  @Override
    +  public int hashCode() {
    +    final int prime = 31;
    +    int result = super.hashCode();
    +    result = prime * result + ((meta == null) ? 0 : meta.hashCode());
    +    result = prime * result
    +        + ((originalQuery == null) ? 0 : originalQuery.hashCode());
    +    result = prime * result + ((efi == null) ? 0 : originalQuery.hashCode());
    --- End diff --
    
    I think this is a typo.
    It should be :
    result = prime * result + ((efi == null) ? 0 : efi.hashCode());
    
    This is a small thing but actually currently make the system not usable when you experiment
different refi variable values. Basically the cache is always hit, even if your refi variables
change dynamically.
    Anyway is really a minimal fix :)


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org


Mime
View raw message