Examples of GlobalSearchResult


Examples of net.relatedwork.shared.dto.GlobalSearchResult

  public GlobalSearchResult execute(GlobalSearch action, ExecutionContext context)
      throws ActionException {
    //TODO: log user ID / session and search query / time stamp - later log what the user clicks in search results

    Index<Node> index = ContextHelper.getSearchIndex(servletContext);
    GlobalSearchResult result = new GlobalSearchResult();
   
    String queryRaw = action.getQuery();
    String query = ContextHelper.prepareQueryString(queryRaw);
   
    IOHelper.log("Send query:" + queryRaw);
    IOHelper.log("Processed query:" + query);

    // setup sort field
    Sort s = new Sort();
    s.setSort(new SortField("score", SortField.DOUBLE, true));

    // run query
    IndexHits<Node> queryReults = index.query(new QueryContext(query).
        defaultOperator(Operator.AND).
        sort(s).
        top(20));

    IOHelper.log("Query returned " + queryReults.size() + " results.");

    for (Node n : queryReults) {
      if (!n.hasProperty(DBNodeProperties.PAGE_RANK_VALUE)) continue;
     
      // Add query Results to result object
      if (NodeType.isAuthorNode(n)) {
        result.addAuthor(authorAccessHandler.authorFromNode(n));
      }

      if (NodeType.isPaperNode(n)){
        result.addPaper(Neo4jToDTOHelper.paperFromNode(n));
      }
    }

    return result;
  }
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.