Package org.apache.lucene.search

Examples of org.apache.lucene.search.SortField


            if (QName.JCR_SCORE.equals(orderProps[i])) {
                // order on jcr:score does not use the natural order as
                // implemented in lucene. score ascending in lucene means that
                // higher scores are first. JCR specs that lower score values
                // are first.
                sortFields.add(new SortField(null, SortField.SCORE, orderSpecs[i]));
            } else {
                try {
                    prop = NameFormat.format(orderProps[i], getNamespaceMappings());
                } catch (NoPrefixDeclaredException e) {
                    // will never happen
                }
                sortFields.add(new SortField(prop, SharedFieldSortComparator.PROPERTIES, !orderSpecs[i]));
            }
        }
        return (SortField[]) sortFields.toArray(new SortField[sortFields.size()]);
    }
View Full Code Here


    FacetSpec ospec = new FacetSpec();
    ospec.setExpandSelection(false);
    br.setFacetSpec("color", ospec);

    br.addSortField(new SortField("date", SortField.Type.CUSTOM, true));

    HashMap<String, List<BrowseFacet>> answer = new HashMap<String, List<BrowseFacet>>();
    answer.put("color",
      Arrays.asList(new BrowseFacet[] { new BrowseFacet("green", 1), new BrowseFacet("red", 1) }));
    doTest(br, 2, answer, new String[] { "6", "7" });
View Full Code Here

    FacetSpec ospec = new FacetSpec();
    ospec.setExpandSelection(false);
    br.setFacetSpec("color", ospec);

    br.addSortField(new SortField("date", SortField.Type.CUSTOM, true));

    HashMap<String, List<BrowseFacet>> answer = new HashMap<String, List<BrowseFacet>>();
    answer.put("color",
      Arrays.asList(new BrowseFacet[] { new BrowseFacet("green", 1), new BrowseFacet("red", 1) }));
    doTest(br, 2, answer, new String[] { "3", "1" });
View Full Code Here

      BoboBrowser browser = new BoboBrowser(reader);

      BrowseRequest browseRequest = new BrowseRequest();
      browseRequest.setCount(10);
      browseRequest.setOffset(0);
      browseRequest.addSortField(new SortField("date", SortField.Type.STRING));

      doTest(browser, browseRequest, 7, null, new String[] { "1", "3", "5", "2", "4", "7", "6" });

    } catch (IOException ioe) {
      if (srcReader != null) {
View Full Code Here

    BrowseSelection sel = new BrowseSelection("date");
    sel.addValue("[2000/01/01 TO 2002/07/07]");
    sel.addValue("[2003/01/01 TO 2005/01/01]");
    br.addSelection(sel);

    br.addSortField(new SortField("date", SortField.Type.CUSTOM, false));

    doTest(br, 5, null, new String[] { "1", "3", "5", "2", "4" });
  }
View Full Code Here

    FacetSpec ospec = new FacetSpec();
    ospec.setExpandSelection(false);
    br.setFacetSpec("color", ospec);

    br.addSortField(new SortField("date", SortField.Type.CUSTOM, false));

    doTest(br, 7, null, new String[] { "1", "3", "5", "2", "4", "7", "6" });
  }
View Full Code Here

    // no sel
    BrowseRequest br = new BrowseRequest();
    br.setCount(10);
    br.setOffset(0);

    br.setSort(new SortField[] { new SortField("color", SortField.Type.CUSTOM, false),
        new SortField("number", SortField.Type.CUSTOM, true) });

    doTest(br, 7, null, new String[] { "5", "4", "6", "3", "2", "1", "7" });

    // now test with serialization
View Full Code Here

    // no sel
    BrowseRequest br = new BrowseRequest();
    br.setCount(10);
    br.setOffset(0);

    br.setSort(new SortField[] { new SortField("number", SortField.Type.CUSTOM, true) });
    doTest(br, 7, null, new String[] { "6", "5", "4", "3", "2", "1", "7" });
    br.setSort(new SortField[] { new SortField("name", SortField.Type.STRING, false) });
    doTest(br, 7, null, new String[] { "7", "4", "6", "2", "3", "1", "5" });

    BrowseSelection sel = new BrowseSelection("color");
    sel.addValue("red");
    br.addSelection(sel);
    br.setSort(new SortField[] { new SortField("number", SortField.Type.CUSTOM, true) });
    doTest(br, 3, null, new String[] { "2", "1", "7" });
    br.setSort(new SortField[] { new SortField("name", SortField.Type.STRING, false) });
    doTest(br, 3, null, new String[] { "7", "2", "1" });

    sel.addValue("blue");
    br.setQuery(new TermQuery(new Term("shape", "square")));
    br.setSort(new SortField[] { new SortField("number", SortField.Type.CUSTOM, true) });
    doTest(br, 3, null, new String[] { "5", "1", "7" });
    br.setSort(new SortField[] { new SortField("name", SortField.Type.STRING, false) });
    doTest(br, 3, null, new String[] { "7", "1", "5" });
  }
View Full Code Here

    FacetSpec spec = new FacetSpec();
    spec.setMaxCount(2);
    spec.setOrderBy(FacetSortSpec.OrderHitsDesc);
    br.setFacetSpec("color", spec);

    br.setSort(new SortField[] { new SortField("number", SortField.Type.CUSTOM, false) });

    HashMap<String, List<BrowseFacet>> answer = new HashMap<String, List<BrowseFacet>>();
    answer.put("color",
      Arrays.asList(new BrowseFacet[] { new BrowseFacet("red", 3), new BrowseFacet("blue", 2) }));
View Full Code Here

      BrowseSelection sel = new BrowseSelection("color");
      sel.addValue("red");
      br.addSelection(sel);

      br.setSort(new SortField[] { new SortField("number", SortField.Type.CUSTOM, false) });
      doTest(br, 2, null, new String[] { "7", "1" });

      FacetSpec ospec = new FacetSpec();
      ospec.setExpandSelection(true);
      br.setFacetSpec("color", ospec);
View Full Code Here

TOP

Related Classes of org.apache.lucene.search.SortField

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.