Package org.apache.lucene.queries.function

Examples of org.apache.lucene.queries.function.FunctionQuery


  }
 
  // Test that FieldScoreQuery returns docs with expected score.
  private void doTestCustomScore(ValueSource valueSource, double dboost) throws Exception {
    float boost = (float) dboost;
    FunctionQuery functionQuery = new FunctionQuery(valueSource);
    IndexReader r = DirectoryReader.open(dir);
    IndexSearcher s = newSearcher(r);

    // regular (boolean) query.
    BooleanQuery q1 = new BooleanQuery();
View Full Code Here


    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

    indexWriter.deleteDocuments(new TermQuery(new Term("id", id)));
  }

  /** scores[] are in docId order */
  protected void checkValueSource(ValueSource vs, float scores[], float delta) throws IOException {
    FunctionQuery q = new FunctionQuery(vs);

//    //TODO is there any point to this check?
//    int expectedDocs[] = new int[scores.length];//fill with ascending 0....length-1
//    for (int i = 0; i < expectedDocs.length; i++) {
//      expectedDocs[i] = i;
View Full Code Here

   
    FacetSearchParams fsp = new FacetSearchParams(new SumValueSourceFacetRequest(new CategoryPath("a"), 10, valueSource, true));
    FacetsCollector fc = FacetsCollector.create(fsp, r, taxo);
    TopScoreDocCollector tsdc = TopScoreDocCollector.create(10, true);
    // score documents by their 'price' field - makes asserting the correct counts for the categories easier
    Query q = new FunctionQuery(new LongFieldSource("price"));
    newSearcher(r).search(q, MultiCollector.wrap(tsdc, fc));
   
    List<FacetResult> res = fc.getFacetResults();
    assertEquals("a (0)\n  1 (6)\n  0 (4)\n", FacetTestUtils.toSimpleString(res.get(0)));
   
View Full Code Here

      @Override public String description() { return "score()"; }
    };
   
    FacetsCollector fc = new FacetsCollector(true);
    // score documents by their 'price' field - makes asserting the correct counts for the categories easier
    Query q = new FunctionQuery(new LongFieldSource("price"));
    FacetsCollector.search(newSearcher(r), q, 10, fc);
    Facets facets = new TaxonomyFacetSumValueSource(taxoReader, config, fc, valueSource);
   
    assertEquals("dim=a path=[] value=10.0 childCount=2\n  1 (6.0)\n  0 (4.0)\n", facets.getTopChildren(10, "a").toString());
   
View Full Code Here

    indexWriter.deleteDocuments(new TermQuery(new Term("id", id)));
  }

  /** scores[] are in docId order */
  protected void checkValueSource(ValueSource vs, float scores[], float delta) throws IOException {
    FunctionQuery q = new FunctionQuery(vs);

//    //TODO is there any point to this check?
//    int expectedDocs[] = new int[scores.length];//fill with ascending 0....length-1
//    for (int i = 0; i < expectedDocs.length; i++) {
//      expectedDocs[i] = i;
View Full Code Here

    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

    return doc;
  }

  /** scores[] are in docId order */
  protected void checkValueSource(ValueSource vs, float scores[], float delta) throws IOException {
    FunctionQuery q = new FunctionQuery(vs);

//    //TODO is there any point to this check?
//    int expectedDocs[] = new int[scores.length];//fill with ascending 0....length-1
//    for (int i = 0; i < expectedDocs.length; i++) {
//      expectedDocs[i] = i;
View Full Code Here

  }
 
  // Test that FieldScoreQuery returns docs with expected score.
  private void doTestCustomScore(ValueSource valueSource, double dboost) throws Exception {
    float boost = (float) dboost;
    FunctionQuery functionQuery = new FunctionQuery(valueSource);
    IndexReader r = DirectoryReader.open(dir);
    IndexSearcher s = new IndexSearcher(r);

    // regular (boolean) query.
    BooleanQuery q1 = new BooleanQuery();
View Full Code Here

    doTestRank(FLOAT_VALUESOURCE);
  }

  // Test that FieldScoreQuery returns docs in expected order.
  private void doTestRank (ValueSource valueSource) throws Exception {
    FunctionQuery functionQuery = new FunctionQuery(valueSource);
    IndexReader r = DirectoryReader.open(dir);
    IndexSearcher s = new IndexSearcher(r);
    log("test: "+ functionQuery);
    QueryUtils.check(random(), functionQuery,s);
    ScoreDoc[] h = s.search(functionQuery, null, 1000).scoreDocs;
View Full Code Here

TOP

Related Classes of org.apache.lucene.queries.function.FunctionQuery

Copyright © 2018 www.massapicom. 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.