Examples of CustomScoreQuery


Examples of org.apache.lucene.queries.CustomScoreQuery

    if (!Double.isNaN(distErrPct))
      args.setDistErrPct(distErrPct);

    if (score) {
      ValueSource valueSource = strategy.makeDistanceValueSource(shape.getCenter());
      return new CustomScoreQuery(strategy.makeQuery(args), new FunctionQuery(valueSource));
    } else {
      //strategy.makeQuery() could potentially score (isn't well defined) so instead we call
      // makeFilter() and wrap

      Filter filter = strategy.makeFilter(args);
View Full Code Here

Examples of org.apache.lucene.queries.CustomScoreQuery

    if (!Double.isNaN(distErrPct))
      args.setDistErrPct(distErrPct);

    if (score) {
      ValueSource valueSource = strategy.makeDistanceValueSource(shape.getCenter());
      return new CustomScoreQuery(strategy.makeQuery(args), new FunctionQuery(valueSource));
    } else {
      //strategy.makeQuery() could potentially score (isn't well defined) so instead we call
      // makeFilter() and wrap

      Filter filter = strategy.makeFilter(args);
View Full Code Here

Examples of org.apache.lucene.queries.CustomScoreQuery

    if (!Double.isNaN(distErrPct))
      args.setDistErrPct(distErrPct);

    if (score) {
      ValueSource valueSource = strategy.makeDistanceValueSource(shape.getCenter());
      return new CustomScoreQuery(strategy.makeQuery(args), new FunctionQuery(valueSource));
    } else {
      //strategy.makeQuery() could potentially score (isn't well defined) so instead we call
      // makeFilter() and wrap

      Filter filter = strategy.makeFilter(args);
View Full Code Here

Examples of org.apache.lucene.search.function.CustomScoreQuery

    //create a term query to search against all documents
    Query tq = new TermQuery(new Term("metafile", "doc"));

    FieldScoreQuery fsQuery = new FieldScoreQuery("geo_distance", Type.FLOAT);

    CustomScoreQuery customScore = new CustomScoreQuery(dq.getQuery(tq),fsQuery){

      @Override
      protected CustomScoreProvider getCustomScoreProvider(IndexReader reader) {
        return new CustomScoreProvider(reader) {
          @Override // TODO: broken, as reader is not used!
          public float customScore(int doc, float subQueryScore, float valSrcScore){
            System.out.println(doc);
            if (dq.distanceFilter.getDistance(doc) == null)
              return 0;

            double distance = dq.distanceFilter.getDistance(doc);
            // boost score shouldn't exceed 1
            if (distance < 1.0d)
              distance = 1.0d;
            //boost by distance is invertly proportional to
            // to distance from center point to location
            float score = (float) ((miles - distance) / miles );
            return score * subQueryScore;
          }
        };
      }
     
    };
    // Create a distance sort
    // As the radius filter has performed the distance calculations
    // already, pass in the filter to reuse the results.
    //
    DistanceFieldComparatorSource dsort = new DistanceFieldComparatorSource(dq.distanceFilter);
    Sort sort = new Sort(new SortField("foo", dsort,false));

    // Perform the search, using the term query, the serial chain filter, and the
    // distance sort
    TopDocs hits = searcher.search(customScore.createWeight(searcher),null, 1000, sort);
    int results = hits.totalHits;
    ScoreDoc[] scoreDocs = hits.scoreDocs;
   
    // Get a list of distances
    Map<Integer,Double> distances = dq.distanceFilter.getDistances();
View Full Code Here

Examples of org.apache.lucene.search.function.CustomScoreQuery

    //create a term query to search against all documents
    Query tq = new TermQuery(new Term("metafile", "doc"));

    FieldScoreQuery fsQuery = new FieldScoreQuery("geo_distance", Type.FLOAT);

    CustomScoreQuery customScore = new CustomScoreQuery(dq.getQuery(tq),fsQuery){

      @Override
      protected CustomScoreProvider getCustomScoreProvider(IndexReader reader) {
        return new CustomScoreProvider(reader) {
          @Override // TODO: broken, as reader is not used!
          public float customScore(int doc, float subQueryScore, float valSrcScore){
            System.out.println(doc);
            if (dq.distanceFilter.getDistance(doc) == null)
              return 0;

            double distance = dq.distanceFilter.getDistance(doc);
            // boost score shouldn't exceed 1
            if (distance < 1.0d)
              distance = 1.0d;
            //boost by distance is invertly proportional to
            // to distance from center point to location
            float score = (float) ((miles - distance) / miles );
            return score * subQueryScore;
          }
        };
      }
     
    };
    // Create a distance sort
    // As the radius filter has performed the distance calculations
    // already, pass in the filter to reuse the results.
    //
    DistanceFieldComparatorSource dsort = new DistanceFieldComparatorSource(dq.distanceFilter);
    Sort sort = new Sort(new SortField("foo", dsort,false));

    // Perform the search, using the term query, the serial chain filter, and the
    // distance sort
    TopDocs hits = searcher.search(customScore.createWeight(searcher),null, 1000, sort);
    int results = hits.totalHits;
    ScoreDoc[] scoreDocs = hits.scoreDocs;

    // Get a list of distances
    Map<Integer,Double> distances = dq.distanceFilter.getDistances();
View Full Code Here

Examples of org.apache.lucene.search.function.CustomScoreQuery

      //create a term query to search against all documents
      Query tq = new TermQuery(new Term("metafile", "doc"));
   
      FieldScoreQuery fsQuery = new FieldScoreQuery("geo_distance", Type.FLOAT);
   
      CustomScoreQuery customScore = new CustomScoreQuery(dq.getQuery(tq),fsQuery){
        @Override
        protected CustomScoreProvider getCustomScoreProvider(IndexReader reader) {
          return new CustomScoreProvider(reader) {
            @Override // TODO: broken, as reader is not used!
            public float customScore(int doc, float subQueryScore, float valSrcScore){
              //System.out.println(doc);
              if (dq.distanceFilter.getDistance(doc) == null)
                return 0;
         
              double distance = dq.distanceFilter.getDistance(doc);
              // boost score shouldn't exceed 1
              if (distance < 1.0d)
                distance = 1.0d;
              //boost by distance is invertly proportional to
              // to distance from center point to location
              float score = (float) ( (miles - distance) / miles );
              return score * subQueryScore;
            }
          };
        }
      };
      // Create a distance sort
      // As the radius filter has performed the distance calculations
      // already, pass in the filter to reuse the results.
      //
      DistanceFieldComparatorSource dsort = new DistanceFieldComparatorSource(dq.distanceFilter);
      Sort sort = new Sort(new SortField("foo", dsort,false));
   
      // Perform the search, using the term query, the serial chain filter, and the
      // distance sort
      TopDocs hits = searcher.search(customScore.createWeight(searcher),null, 1000, sort);
      int results = hits.totalHits;
      ScoreDoc[] scoreDocs = hits.scoreDocs;
   
      // Get a list of distances
      Map<Integer,Double> distances = dq.distanceFilter.getDistances();
View Full Code Here

Examples of org.apache.lucene.search.function.CustomScoreQuery

      System.out.println(dq);
      //create a term query to search against all documents
      Query tq = new TermQuery(new Term("metafile", "doc"));
     
      FieldScoreQuery fsQuery = new FieldScoreQuery("geo_distance", Type.FLOAT);
      CustomScoreQuery customScore = new CustomScoreQuery(tq,fsQuery){
        @Override
        protected CustomScoreProvider getCustomScoreProvider(IndexReader reader) {
          return new CustomScoreProvider(reader) {
              @Override // TODO: broken, as reader is not used!
              public float customScore(int doc, float subQueryScore, float valSrcScore){
              //System.out.println(doc);
              if (dq.distanceFilter.getDistance(doc) == null)
                return 0;
           
              double distance = dq.distanceFilter.getDistance(doc);
              // boost score shouldn't exceed 1
              if (distance < 1.0d)
                distance = 1.0d;
              //boost by distance is invertly proportional to
              // to distance from center point to location
              float score = (float) ( (miles - distance) / miles );
              return score * subQueryScore;
            }
          };
        }
      };
      // Create a distance sort
      // As the radius filter has performed the distance calculations
      // already, pass in the filter to reuse the results.
      //
      DistanceFieldComparatorSource dsort = new DistanceFieldComparatorSource(dq.distanceFilter);
      Sort sort = new Sort(new SortField("foo", dsort));
     
      // Perform the search, using the term query, the serial chain filter, and the
      // distance sort
      TopDocs hits = searcher.search(customScore.createWeight(searcher),dq.getFilter(), 1000); //,sort);
      int results = hits.totalHits;
      ScoreDoc[] scoreDocs = hits.scoreDocs;
     
      // Get a list of distances
      Map<Integer,Double> distances = dq.distanceFilter.getDistances();
View Full Code Here

Examples of org.apache.lucene.search.function.CustomScoreQuery

    //create a term query to search against all documents
    Query tq = new TermQuery(new Term("metafile", "doc"));

    FieldScoreQuery fsQuery = new FieldScoreQuery("geo_distance", Type.FLOAT);

    CustomScoreQuery customScore = new CustomScoreQuery(dq.getQuery(tq),fsQuery){

      @Override
      protected CustomScoreProvider getCustomScoreProvider(IndexReader reader) {
        return new CustomScoreProvider(reader) {
          @Override // TODO: broken, as reader is not used!
          public float customScore(int doc, float subQueryScore, float valSrcScore){
            if (VERBOSE) System.out.println(doc);
            if (dq.distanceFilter.getDistance(doc) == null)
              return 0;

            double distance = dq.distanceFilter.getDistance(doc);
            // boost score shouldn't exceed 1
            if (distance < 1.0d)
              distance = 1.0d;
            //boost by distance is invertly proportional to
            // to distance from center point to location
            float score = (float) ((miles - distance) / miles );
            return score * subQueryScore;
          }
        };
      }
     
    };
    // Create a distance sort
    // As the radius filter has performed the distance calculations
    // already, pass in the filter to reuse the results.
    //
    DistanceFieldComparatorSource dsort = new DistanceFieldComparatorSource(dq.distanceFilter);
    Sort sort = new Sort(new SortField("foo", dsort,false));

    // Perform the search, using the term query, the serial chain filter, and the
    // distance sort
    TopDocs hits = searcher.search(customScore.createWeight(searcher),null, 1000, sort);
    int results = hits.totalHits;
    ScoreDoc[] scoreDocs = hits.scoreDocs;
   
    // Get a list of distances
    Map<Integer,Double> distances = dq.distanceFilter.getDistances();
View Full Code Here

Examples of org.apache.lucene.search.function.CustomScoreQuery

    //create a term query to search against all documents
    Query tq = new TermQuery(new Term("metafile", "doc"));

    FieldScoreQuery fsQuery = new FieldScoreQuery("geo_distance", Type.FLOAT);

    CustomScoreQuery customScore = new CustomScoreQuery(dq.getQuery(tq),fsQuery){

      @Override
      protected CustomScoreProvider getCustomScoreProvider(IndexReader reader) {
        return new CustomScoreProvider(reader) {
          @Override // TODO: broken, as reader is not used!
          public float customScore(int doc, float subQueryScore, float valSrcScore){
            if (VERBOSE) System.out.println(doc);
            if (dq.distanceFilter.getDistance(doc) == null)
              return 0;

            double distance = dq.distanceFilter.getDistance(doc);
            // boost score shouldn't exceed 1
            if (distance < 1.0d)
              distance = 1.0d;
            //boost by distance is invertly proportional to
            // to distance from center point to location
            float score = (float) ((miles - distance) / miles );
            return score * subQueryScore;
          }
        };
      }
     
    };
    // Create a distance sort
    // As the radius filter has performed the distance calculations
    // already, pass in the filter to reuse the results.
    //
    DistanceFieldComparatorSource dsort = new DistanceFieldComparatorSource(dq.distanceFilter);
    Sort sort = new Sort(new SortField("foo", dsort,false));

    // Perform the search, using the term query, the serial chain filter, and the
    // distance sort
    TopDocs hits = searcher.search(customScore.createWeight(searcher),null, 1000, sort);
    int results = hits.totalHits;
    ScoreDoc[] scoreDocs = hits.scoreDocs;

    // Get a list of distances
    Map<Integer,Double> distances = dq.distanceFilter.getDistances();
View Full Code Here

Examples of org.apache.lucene.search.function.CustomScoreQuery

      //create a term query to search against all documents
      Query tq = new TermQuery(new Term("metafile", "doc"));
   
      FieldScoreQuery fsQuery = new FieldScoreQuery("geo_distance", Type.FLOAT);
   
      CustomScoreQuery customScore = new CustomScoreQuery(dq.getQuery(tq),fsQuery){
        @Override
        protected CustomScoreProvider getCustomScoreProvider(IndexReader reader) {
          return new CustomScoreProvider(reader) {
            @Override // TODO: broken, as reader is not used!
            public float customScore(int doc, float subQueryScore, float valSrcScore){
              if (VERBOSE) System.out.println(doc);
              if (dq.distanceFilter.getDistance(doc) == null)
                return 0;
         
              double distance = dq.distanceFilter.getDistance(doc);
              // boost score shouldn't exceed 1
              if (distance < 1.0d)
                distance = 1.0d;
              //boost by distance is invertly proportional to
              // to distance from center point to location
              float score = (float) ( (miles - distance) / miles );
              return score * subQueryScore;
            }
          };
        }
      };
      // Create a distance sort
      // As the radius filter has performed the distance calculations
      // already, pass in the filter to reuse the results.
      //
      DistanceFieldComparatorSource dsort = new DistanceFieldComparatorSource(dq.distanceFilter);
      Sort sort = new Sort(new SortField("foo", dsort,false));
   
      // Perform the search, using the term query, the serial chain filter, and the
      // distance sort
      TopDocs hits = searcher.search(customScore.createWeight(searcher),null, 1000, sort);
      int results = hits.totalHits;
      ScoreDoc[] scoreDocs = hits.scoreDocs;
   
      // Get a list of distances
      Map<Integer,Double> distances = dq.distanceFilter.getDistances();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.