当前位置: 首页>>代码示例>>Java>>正文


Java MapFieldSelector类代码示例

本文整理汇总了Java中org.apache.lucene.document.MapFieldSelector的典型用法代码示例。如果您正苦于以下问题:Java MapFieldSelector类的具体用法?Java MapFieldSelector怎么用?Java MapFieldSelector使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


MapFieldSelector类属于org.apache.lucene.document包,在下文中一共展示了MapFieldSelector类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: collect

import org.apache.lucene.document.MapFieldSelector; //导入依赖的package包/类
@SuppressWarnings("nls")
@Override
public void collect(int docNum) throws IOException
{
	Document doc = reader.document(docNum, new MapFieldSelector(FreeTextQuery.FIELD_UNIQUE, FreeTextQuery.FIELD_ID,
		FreeTextQuery.FIELD_INDEXEDTIME, FreeTextQuery.FIELD_INSTITUTION));
	String unique = doc.get(FreeTextQuery.FIELD_UNIQUE);
	long itemId = Long.parseLong(doc.get(FreeTextQuery.FIELD_ID));
	long instId = Long.parseLong(doc.get(FreeTextQuery.FIELD_INSTITUTION));
	String timeStr = doc.get(FreeTextQuery.FIELD_INDEXEDTIME);

	if( unique == null || timeStr == null )
	{
		LOGGER.warn("Corrupt document '" + docNum + "' in index. {unique:" + unique + ", time:" + timeStr + "}");
	}
	else
	{
		compareDate(itemId, instId, Long.parseLong(timeStr));
	}
}
 
开发者ID:equella,项目名称:Equella,代码行数:21,代码来源:AbstractCompareDateCollector.java

示例2: queryFieldByUuid

import org.apache.lucene.document.MapFieldSelector; //导入依赖的package包/类
/**
 * Returns the field values associated with a document
 * @param context the operation context
 * @param fieldName the field name
 * @param uuid the document uuid
 * @return the field values (null if not found)
 * @throws CorruptIndexException if the index is corrupt
 * @throws IOException if an I/O exception occurs
 */
public String[] queryFieldByUuid(TocContext context, String fieldName, String uuid) 
  throws CorruptIndexException, IOException {
  TermDocs termDocs = null;
  try {
    uuid = Val.chkStr(uuid);
    if (uuid.length() > 0) {
      IndexSearcher searcher = this.getSearcher(context);
      IndexReader reader = searcher.getIndexReader();
      MapFieldSelector selector = new MapFieldSelector(new String[]{fieldName});
      termDocs = reader.termDocs();
      termDocs.seek(new Term(Storeables.FIELD_UUID,uuid));
      if (termDocs.next()) {
        Document document = reader.document(termDocs.doc(),selector);
        return document.getValues(fieldName);
      }
    }
  } finally {
    try {if (termDocs != null) termDocs.close();} catch (Exception ef) {}
  }
  return null;
}
 
开发者ID:GeoinformationSystems,项目名称:GeoprocessingAppstore,代码行数:31,代码来源:TocIndexAdapter.java

示例3: queryAcls

import org.apache.lucene.document.MapFieldSelector; //导入依赖的package包/类
/**
 * Queries the ACL values indexed for a document.
 * @param uuid the document UUID
 * @return the ACL values (can be null)
 * @throws CatalogIndexException if an exception occurs
 */
@Override
public String[] queryAcls(String uuid)  throws CatalogIndexException {
  ArrayList<String> values = new ArrayList<String>();
  IndexSearcher searcher = null;
  TermDocs termDocs = null;
  try {
    uuid = Val.chkStr(uuid);
    if (uuid.length() > 0) {
      searcher = newSearcher();
      String[] aFields = new String[]{Storeables.FIELD_ACL};
      MapFieldSelector selector = new MapFieldSelector(aFields);
      searcher = newSearcher();
      IndexReader reader = searcher.getIndexReader();
      termDocs = reader.termDocs();
      termDocs.seek(new Term(Storeables.FIELD_UUID,uuid));
      if (termDocs.next()) {
        Document document = reader.document(termDocs.doc(),selector);
        Field[] fields = document.getFields(Storeables.FIELD_ACL);
        if ((fields != null) && (fields.length > 0)) {
          for (Field field: fields) {
            values.add(field.stringValue());
          }
        }
      } 
    }
  } catch (IOException e) {
    String sMsg = "Error accessing index:\n "+Val.chkStr(e.getMessage());
    throw new CatalogIndexException(sMsg,e);
  } finally {
    try {if (termDocs != null) termDocs.close();} catch (Exception ef) {}
    closeSearcher(searcher);
  }
  return values.toArray(new String[0]);
}
 
开发者ID:GeoinformationSystems,项目名称:GeoprocessingAppstore,代码行数:41,代码来源:LuceneIndexAdapter.java

示例4: queryModifiedDate

import org.apache.lucene.document.MapFieldSelector; //导入依赖的package包/类
/**
 * Queries the system modified date associated with an indexed document.
 * @param uuid the document UUID
 * @return the update date (null if none was found)
 * @throws CatalogIndexException if an exception occurs
 */
@Override
public Timestamp queryModifiedDate(String uuid) throws CatalogIndexException {
  Timestamp tsUpdate = null;
  IndexSearcher searcher = null;
  TermDocs termDocs = null;
  try {
    uuid = Val.chkStr(uuid);
    if (uuid.length() > 0) {
      String[] aFields = new String[]{Storeables.FIELD_DATEMODIFIED};
      MapFieldSelector selector = new MapFieldSelector(aFields);
      searcher = newSearcher();
      IndexReader reader = searcher.getIndexReader();
      termDocs = reader.termDocs();
      termDocs.seek(new Term(Storeables.FIELD_UUID,uuid));
      if (termDocs.next()) {
        Document document = reader.document(termDocs.doc(),selector);
        String sUpdate = document.get(Storeables.FIELD_DATEMODIFIED);
        tsUpdate = new Timestamp(Long.valueOf(sUpdate));
      }
    }
  } catch (IOException e) {
    String sMsg = "Error accessing index:\n "+Val.chkStr(e.getMessage());
    throw new CatalogIndexException(sMsg,e);
  } finally {
    try {if (termDocs != null) termDocs.close();} catch (Exception ef) {}
    closeSearcher(searcher);
  }
  return tsUpdate;
}
 
开发者ID:GeoinformationSystems,项目名称:GeoprocessingAppstore,代码行数:36,代码来源:LuceneIndexAdapter.java

示例5: SearchHitsTuples

import org.apache.lucene.document.MapFieldSelector; //导入依赖的package包/类
public SearchHitsTuples(final String subject, final String predicate, final String object) throws TuplesException {
  if (logger.isDebugEnabled()) {
    logger.debug("Searching for " + subject + " : " + predicate + " : " + object);
  }

  // run the query
  try {
    hits = fullTextStringIndex.find(subject, predicate, object);
  } catch (FullTextStringIndexException e) {
    throw new TuplesException("Couldn't generate answer from text index: subject='" + subject +
                              "', predicate='" + predicate + "', object='" + object + "'", e);
  }

  // sort the result in doc-id order for faster document retrieval
  hits.sort();

  // make sure we only load those fields we need (=> faster document retrieval)
  List<String> load = new ArrayList<String>(3);
  if (subject == null) load.add(FullTextStringIndex.SUBJECT_KEY);
  if (predicate == null) load.add(FullTextStringIndex.PREDICATE_KEY);
  if (object == null) load.add(FullTextStringIndex.LITERAL_KEY);
  fieldSelector = new MapFieldSelector(load);

  // prepare for iterating
  document = null;
  nextDocumentIndex = 0;

  variableList.addAll(constrVariableList);
  luceneKeyList.addAll(constrLuceneKeyList);

  setVariables(variableList);
}
 
开发者ID:quoll,项目名称:mulgara,代码行数:33,代码来源:FullTextStringIndexTuples.java


注:本文中的org.apache.lucene.document.MapFieldSelector类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。