Пример #1
0
  private void renderDocuments()
      throws IOException, ParseException, SyntaxError, SearchLibException {
    AbstractSearchRequest searchRequest = result.getRequest();
    int start = searchRequest.getStart();
    int end = result.getDocumentCount() + searchRequest.getStart();

    for (int i = start; i < end; i++) this.renderDocument(i);
  }
Пример #2
0
 public FileInfo getFileInfo(String uriString)
     throws SearchLibException, UnsupportedEncodingException, URISyntaxException {
   AbstractSearchRequest searchRequest =
       (AbstractSearchRequest) dbClient.getNewRequest(SearchTemplate.fileInfo.name());
   StringBuilder sb = new StringBuilder();
   FileItemFieldEnum.INSTANCE.uri.addQuery(sb, uriString, true);
   searchRequest.setQueryString(sb.toString());
   searchRequest.setStart(0);
   searchRequest.setRows(1);
   AbstractResultSearch<?> result = (AbstractResultSearch<?>) dbClient.request(searchRequest);
   if (result.getNumFound() == 0) return null;
   return new FileInfo(result.getDocument(0));
 }
Пример #3
0
 public FacetResult(AbstractResultSearch<?> result, String field) {
   terms = new ArrayList<FacetFieldItem>();
   FacetList facetList = result.getFacetList();
   fieldName = field;
   for (FacetItem facet : facetList.getByField(field.trim()))
     terms.add(new FacetFieldItem(facet.getCount(), facet.getTerm()));
 }
Пример #4
0
 public void getFileInfoList(URI parentDirectory, Map<String, FileInfo> indexFileMap)
     throws SearchLibException, UnsupportedEncodingException, URISyntaxException {
   AbstractSearchRequest searchRequest =
       (AbstractSearchRequest) dbClient.getNewRequest(SearchTemplate.fileInfo.name());
   StringBuilder sb = new StringBuilder();
   String parentUriString = parentDirectory.toASCIIString();
   FileItemFieldEnum.INSTANCE.directory.addQuery(sb, parentUriString, true);
   searchRequest.setQueryString(sb.toString());
   searchRequest.setStart(0);
   searchRequest.setRows(Integer.MAX_VALUE);
   AbstractResultSearch<?> result = (AbstractResultSearch<?>) dbClient.request(searchRequest);
   int l = result.getNumFound();
   for (int i = 0; i < l; i++) {
     FileInfo fileInfo = new FileInfo(result.getDocument(i));
     indexFileMap.put(fileInfo.getUri(), fileInfo);
   }
 }
Пример #5
0
 public long getFileList(
     AbstractSearchRequest searchRequest, long start, long rows, List<FileItem> list)
     throws SearchLibException {
   searchRequest.reset();
   searchRequest.setStart((int) start);
   searchRequest.setRows((int) rows);
   try {
     AbstractResultSearch<?> result = (AbstractResultSearch<?>) dbClient.request(searchRequest);
     if (list != null) for (ResultDocument doc : result) list.add(getNewFileItem(doc));
     return result.getNumFound();
   } catch (RuntimeException e) {
     throw new SearchLibException(e);
   } catch (UnsupportedEncodingException e) {
     throw new SearchLibException(e);
   } catch (URISyntaxException e) {
     throw new SearchLibException(e);
   }
 }
Пример #6
0
  public long getFiles(
      AbstractSearchRequest searchRequest,
      ItemField orderBy,
      boolean orderAsc,
      long start,
      long rows,
      List<FileItem> list)
      throws SearchLibException {
    searchRequest.setStart((int) start);
    searchRequest.setRows((int) rows);
    try {
      if (orderBy != null) orderBy.addSort(searchRequest, !orderAsc);
      AbstractResultSearch<?> result = (AbstractResultSearch<?>) dbClient.request(searchRequest);
      if (list != null) for (ResultDocument doc : result) list.add(getNewFileItem(doc));
      return result.getNumFound();

    } catch (IOException e) {
      throw new SearchLibException(e);
    } catch (RuntimeException e) {
      throw new SearchLibException(e);
    } catch (URISyntaxException e) {
      throw new SearchLibException(e);
    }
  }
Пример #7
0
  private void renderDocument(int i)
      throws IOException, ParseException, SyntaxError, SearchLibException {
    ResultDocument doc = result.getDocument(i, null);
    for (ReturnField field : searchRequest.getReturnFieldList()) {
      renderField(doc, field);
      if (field.getName() != null && !field.getName().equals("")) writer.print(',');
    }
    for (SnippetField field : searchRequest.getSnippetFieldList()) {
      renderSnippetValue(doc, field);
      String fName = field.getName();
      if (fName != null && fName.length() > 0) writer.print(',');
    }

    writer.print('\n');
  }
Пример #8
0
 public RenderCSV(AbstractResultSearch<?> result) {
   this.result = result;
   this.searchRequest = result.getRequest();
 }