Package org.apache.lucene.search

Examples of org.apache.lucene.search.SortField


    br.addSelection(sel);

    FacetSpec ospec = new FacetSpec();
    br.setFacetSpec("compactnum", ospec);

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

    HashMap<String, List<BrowseFacet>> answer = new HashMap<String, List<BrowseFacet>>();

    answer.put(
      "compactnum",
View Full Code Here


    sel.addValue("cool");
    br.addSelection(sel);

    FacetSpec ospec = new FacetSpec();
    br.setFacetSpec("multiwithweight", ospec);
    br.setSort(new SortField[] { new SortField("multiwithweight", SortField.Type.CUSTOM, true) });
    HashMap<String, List<BrowseFacet>> answer = new HashMap<String, List<BrowseFacet>>();

    answer.put("multiwithweight",
      Arrays.asList(new BrowseFacet[] { new BrowseFacet("cool", 3), new BrowseFacet("good", 2) }));
View Full Code Here

    sel.addValue("007");
    br.addSelection(sel);

    FacetSpec ospec = new FacetSpec();
    br.setFacetSpec("multinum", ospec);
    br.setSort(new SortField[] { new SortField("multinum", SortField.Type.CUSTOM, true) });
    HashMap<String, List<BrowseFacet>> answer = new HashMap<String, List<BrowseFacet>>();

    answer.put(
      "multinum",
      Arrays.asList(new BrowseFacet[] { new BrowseFacet("001", 3), new BrowseFacet("002", 1),
View Full Code Here

   */
  public void testMultiBrowser() throws Exception {
    BrowseRequest browseRequest = new BrowseRequest();
    browseRequest.setCount(10);
    browseRequest.setOffset(0);
    browseRequest.addSortField(new SortField("date", SortField.Type.CUSTOM));

    BrowseSelection colorSel = new BrowseSelection("color");
    colorSel.addValue("red");
    browseRequest.addSelection(colorSel);

    BrowseSelection tageSel = new BrowseSelection("tag");
    tageSel.addValue("rabbit");
    browseRequest.addSelection(tageSel);

    FacetSpec colorFacetSpec = new FacetSpec();
    colorFacetSpec.setExpandSelection(true);
    colorFacetSpec.setOrderBy(FacetSortSpec.OrderHitsDesc);

    FacetSpec tagFacetSpec = new FacetSpec();

    browseRequest.setFacetSpec("color", colorFacetSpec);
    browseRequest.setFacetSpec("tag", tagFacetSpec);

    FacetSpec shapeSpec = new FacetSpec();
    shapeSpec.setOrderBy(FacetSortSpec.OrderHitsDesc);
    browseRequest.setFacetSpec("shape", shapeSpec);

    FacetSpec dateSpec = new FacetSpec();
    dateSpec.setExpandSelection(true);
    browseRequest.setFacetSpec("date", dateSpec);

    BoboBrowser boboBrowser = newBrowser();

    browseRequest
        .setSort(new SortField[] { new SortField("compactnum", SortField.Type.CUSTOM, true) });

    MultiBoboBrowser multiBoboBrowser = new MultiBoboBrowser(new Browsable[] { boboBrowser,
        boboBrowser });
    BrowseResult mergedResult = multiBoboBrowser.browse(browseRequest);

    HashMap<String, List<BrowseFacet>> answer = new HashMap<String, List<BrowseFacet>>();
    answer.put("color",
      Arrays.asList(new BrowseFacet[] { new BrowseFacet("red", 4), new BrowseFacet("green", 2) }));
    answer.put(
      "tag",
      Arrays.asList(new BrowseFacet[] { new BrowseFacet("animal", 2), new BrowseFacet("dog", 2),
          new BrowseFacet("humane", 2), new BrowseFacet("pet", 2), new BrowseFacet("rabbit", 4) }));
    answer.put("shape", Arrays.asList(new BrowseFacet[] { new BrowseFacet("square", 4) }));
    answer.put("date",
      Arrays.asList(new BrowseFacet[] { new BrowseFacet("[2000/01/01 TO 2003/05/05]", 2) }));

    doTest(mergedResult, browseRequest, 4, answer, new String[] { "7", "7", "1", "1" });

    browseRequest
        .setSort(new SortField[] { new SortField("multinum", SortField.Type.CUSTOM, true) });
    mergedResult = multiBoboBrowser.browse(browseRequest);
    doTest(mergedResult, browseRequest, 4, answer, new String[] { "7", "7", "1", "1" });
    mergedResult.close();
    multiBoboBrowser.close();
  }
View Full Code Here

      }
    }

    DocComparatorSource compSource;
    if (sort.length == 1) {
      SortField sf = convert(browser, sort[0]);
      compSource = getComparatorSource(browser, sf);
    } else {
      DocComparatorSource[] compSources = new DocComparatorSource[sort.length];
      for (int i = 0; i < sort.length; ++i) {
        compSources[i] = getComparatorSource(browser, convert(browser, sort[i]));
View Full Code Here

  public void testRawDataRetrieval() throws Exception {
    BrowseRequest br = new BrowseRequest();
    br.setCount(10);
    br.setOffset(0);
    br.setSort(new SortField[] { new SortField("date", SortField.Type.CUSTOM, false) });
    BrowseResult result = null;
    BoboBrowser boboBrowser = null;
    SimpleDateFormat dateFormatter = new SimpleDateFormat("yyyy/MM/dd");
    try {
      boboBrowser = newBrowser();
View Full Code Here

    FacetSpec charOutput = new FacetSpec();
    charOutput.setMaxCount(50);
    charOutput.setOrderBy(FacetSortSpec.OrderHitsDesc);

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

    HashMap<String, List<BrowseFacet>> answer = new HashMap<String, List<BrowseFacet>>();
    answer.put(
      "char",
      Arrays.asList(new BrowseFacet[] { new BrowseFacet("a", 1), new BrowseFacet("i", 1),
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("blue", 2), new BrowseFacet("green", 1),
View Full Code Here

    public TopDocs getRecentDocuments(int n) throws EventSearchServiceException {
        try {
            long current = new Date().getTime();
            Query query = new TermRangeQuery("DEADLINE-TIME", TimeUtil.getTimeString(current), TimeUtil.getTimeString(Long.MAX_VALUE), true, true);

            Sort sort = new Sort(new SortField("CREATED-AT", SortField.STRING, true));

            return indexSearcher.search(query, null, n, sort);
        } catch (IOException e) {
            throw new EventSearchServiceException(e);
        }
View Full Code Here

    public TopDocs getRecentCategoryDocuments(String category, int maxDocument) throws EventSearchServiceException, IllegalArgumentException {
        if (!EventCategory.isValidCategoryName(category)) {
            throw new IllegalArgumentException("Unknown category");
        }
        Query query = new TermQuery(new Term("CATEGORY", category));
        Sort sort = new Sort(new SortField("CREATED-AT", SortField.STRING, true));
        try {
            return indexSearcher.search(query, null, maxDocument, sort);
        } catch (IOException e) {
            throw new EventSearchServiceException(e);
        }
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.