Package org.apache.lucene.search

Examples of org.apache.lucene.search.Sort


    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

                }
            }

            // TODO: このへんの定数なんとかするべき。いろんなところに散らばっていて使いにくい。

            Sort sort;
            if ("score".equals(sortOrder)) {
                sort = new Sort(SortField.FIELD_SCORE, new SortField("BEGIN-TIME", SortField.STRING));
            } else if ("createdAt".equals(sortOrder)) {
                sort = new Sort(new SortField("CREATED-AT", SortField.STRING, true));
            } else if ("deadline".equals(sortOrder)) {
                sort = new Sort(new SortField("DEADLINE-TIME", SortField.STRING));
            } else if ("deadline-r".equals(sortOrder)) {
                sort = new Sort(new SortField("DEADLINE-TIME", SortField.STRING, true));
            } else if ("beginDate".equals(sortOrder)) {
                sort = new Sort(new SortField("BEGIN-TIME", SortField.STRING));
            } else if ("beginDate-r".equals(sortOrder)) {
                sort = new Sort(new SortField("BEGIN-TIME", SortField.STRING, true));
            } else {
                // 決まってない場合は、score 順にする。
                sort = new Sort(SortField.FIELD_SCORE, new SortField("BEGIN-TIME", SortField.STRING));
            }

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

    //query
    Query query = new TermQuery(new Term("field", "sample"));
   
    //sort
    Sort sort = new Sort("sort");
   
    //document
    Document document = new Document();
    document.add(new Field("field", "a sample", Field.Store.YES, Field.Index.TOKENIZED));
    document.add(new Field("filter", "a sample filter", Field.Store.YES, Field.Index.TOKENIZED));
View Full Code Here

    //query
    Query query = new TermQuery(new Term("field", "sample"));
   
    //sort
    Sort sort = new Sort("sort");
   
    //document
    Document document = new Document();
    document.add(new Field("field", "a sample", Field.Store.YES, Field.Index.TOKENIZED));
    document.add(new Field("filter", "a sample filter", Field.Store.YES, Field.Index.TOKENIZED));
View Full Code Here

    //filter
    TermQuery filterQuery = new TermQuery(new Term("filter", "another"));
    Filter filter = new QueryFilter(filterQuery);

    //sort
    Sort sort = new Sort("sort");
   
    //document
    Document document = new Document();
    document.add(new Field("field", "a sample", Field.Store.YES, Field.Index.TOKENIZED));
    document.add(new Field("filter", "a sample filter", Field.Store.YES, Field.Index.TOKENIZED));
View Full Code Here

    //filter
    TermQuery filterQuery = new TermQuery(new Term("filter", "another"));
    Filter filter = new QueryFilter(filterQuery);

    //sort
    Sort sort = new Sort("sort");
   
    //document
    Document document = new Document();
    document.add(new Field("field", "a sample", Field.Store.YES, Field.Index.TOKENIZED));
    document.add(new Field("filter", "a sample filter", Field.Store.YES, Field.Index.TOKENIZED));
View Full Code Here

  /**
   * {@inheritDoc}
   */
  public void process(ResponseBuilder rb, ShardRequest shardRequest) {
    SortSpec ss = rb.getSortSpec();
    Sort groupSort = rb.getGroupingSpec().getGroupSort();
    String[] fields = rb.getGroupingSpec().getFields();

    Map<String, List<Collection<SearchGroup<String>>>> commandSearchGroups = new HashMap<String, List<Collection<SearchGroup<String>>>>();
    Map<String, Map<SearchGroup<String>, String>> tempSearchGroupToShard = new HashMap<String, Map<SearchGroup<String>, String>>();
    for (String field : fields) {
View Full Code Here

  /**
   * {@inheritDoc}
   */
  @SuppressWarnings("unchecked")
  public void process(ResponseBuilder rb, ShardRequest shardRequest) {
    Sort groupSort = rb.getGroupingSpec().getGroupSort();
    String[] fields = rb.getGroupingSpec().getFields();
    String[] queries = rb.getGroupingSpec().getQueries();
    Sort sortWithinGroup = rb.getGroupingSpec().getSortWithinGroup();

    // If group.format=simple group.offset doesn't make sense
    int groupOffsetDefault;
    if (rb.getGroupingSpec().getResponseFormat() == Grouping.Format.simple || rb.getGroupingSpec().isMain()) {
      groupOffsetDefault = 0;
View Full Code Here

    }

    int start = startS != null ? Integer.parseInt(startS) : 0;
    int rows = rowsS != null ? Integer.parseInt(rowsS) : 10;

    Sort sort = null;
    if( sortStr != null ) {
      sort = QueryParsing.parseSort(sortStr, req);
    }
    return new SortSpec( sort, start, rows );
  }
View Full Code Here

TOP

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

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.