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


Java FieldType.setTokenized方法代码示例

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


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

示例1: createWith

import org.apache.lucene.document.FieldType; //导入方法依赖的package包/类
/**
 * Creates Lucene Document using two strings: body and title
 *
 * @return resulted document
 */
public static Document createWith(final String titleStr, final String bodyStr) {
    final Document document = new Document();

    final FieldType textIndexedType = new FieldType();
    textIndexedType.setStored(true);
    textIndexedType.setIndexOptions(IndexOptions.DOCS);
    textIndexedType.setTokenized(true);

    //index title
    Field title = new Field("title", titleStr, textIndexedType);
    //index body
    Field body = new Field("body", bodyStr, textIndexedType);

    document.add(title);
    document.add(body);
    return document;
}
 
开发者ID:c0rp-aubakirov,项目名称:lucene-tutorial,代码行数:23,代码来源:MessageToDocument.java

示例2: LuceneUtil

import org.apache.lucene.document.FieldType; //导入方法依赖的package包/类
public LuceneUtil(JasperReportsContext jasperReportsContext, boolean isCaseSensitive, boolean isWholeWordsOnly, boolean removeAccents) {
	this.isCaseSensitive = isCaseSensitive;
	this.isWholeWordsOnly = isWholeWordsOnly;
	this.removeAccents = removeAccents;

	this.noneSelector = JRStyledTextAttributeSelector.getNoneSelector(jasperReportsContext);
	this.styledTextUtil = JRStyledTextUtil.getInstance(jasperReportsContext);
	
	fieldType = new FieldType();
	fieldType.setIndexed(true);
	fieldType.setTokenized(true);
	fieldType.setStored(true);
	fieldType.setStoreTermVectors(true);
	fieldType.setStoreTermVectorPositions(true);
	fieldType.setStoreTermVectorOffsets(true);
	fieldType.freeze();
}
 
开发者ID:TIBCOSoftware,项目名称:jasperreports,代码行数:18,代码来源:LuceneUtil.java

示例3: addDoc

import org.apache.lucene.document.FieldType; //导入方法依赖的package包/类
private static void addDoc(RandomIndexWriter iw, int i) throws Exception {
  Document d = new Document();
  Field f;
  int scoreAndID = i + 1;

  FieldType customType = new FieldType(TextField.TYPE_STORED);
  customType.setTokenized(false);
  customType.setOmitNorms(true);
  
  f = newField(ID_FIELD, id2String(scoreAndID), customType); // for debug purposes
  d.add(f);

  FieldType customType2 = new FieldType(TextField.TYPE_NOT_STORED);
  customType2.setOmitNorms(true);
  f = newField(TEXT_FIELD, "text of doc" + scoreAndID + textLine(i), customType2); // for regular search
  d.add(f);

  f = newField(INT_FIELD, "" + scoreAndID, customType); // for function scoring
  d.add(f);

  f = newField(FLOAT_FIELD, scoreAndID + ".000", customType); // for function scoring
  d.add(f);

  iw.addDocument(d);
  log("added: " + d);
}
 
开发者ID:europeana,项目名称:search,代码行数:27,代码来源:FunctionTestSetup.java

示例4: isAHit

import org.apache.lucene.document.FieldType; //导入方法依赖的package包/类
private boolean isAHit(Query q, String content, Analyzer analyzer) throws IOException{
  Directory ramDir = newDirectory();
  RandomIndexWriter writer = new RandomIndexWriter(random(), ramDir, analyzer);
  Document doc = new Document();
  FieldType fieldType = new FieldType();
  fieldType.setIndexed(true);
  fieldType.setTokenized(true);
  fieldType.setStored(true);
  Field field = new Field(FIELD, content, fieldType);
  doc.add(field);
  writer.addDocument(doc);
  writer.close();
  DirectoryReader ir = DirectoryReader.open(ramDir);
  IndexSearcher is = new IndexSearcher(ir);
    
  int hits = is.search(q, 10).totalHits;
  ir.close();
  ramDir.close();
  if (hits == 1){
    return true;
  } else {
    return false;
  }

}
 
开发者ID:europeana,项目名称:search,代码行数:26,代码来源:TestAnalyzingQueryParser.java

示例5: beforeClass

import org.apache.lucene.document.FieldType; //导入方法依赖的package包/类
@BeforeClass
public static void beforeClass() throws Exception {
  String[] data = new String[] { "A 1 2 3 4 5 6", "Z       4 5 6", null,
      "B   2   4 5 6", "Y     3   5 6", null, "C     3     6",
      "X       4 5 6" };

  small = newDirectory();
  RandomIndexWriter writer = new RandomIndexWriter(random(), small, 
      newIndexWriterConfig(
          new MockAnalyzer(random(), MockTokenizer.WHITESPACE, false)).setMergePolicy(newLogMergePolicy()));

  FieldType customType = new FieldType(TextField.TYPE_STORED);
  customType.setTokenized(false);
  for (int i = 0; i < data.length; i++) {
    Document doc = new Document();
    doc.add(newField("id", String.valueOf(i), customType));// Field.Keyword("id",String.valueOf(i)));
    doc.add(newField("all", "all", customType));// Field.Keyword("all","all"));
    if (null != data[i]) {
      doc.add(newTextField("data", data[i], Field.Store.YES));// Field.Text("data",data[i]));
    }
    writer.addDocument(doc);
  }

  reader = writer.getReader();
  writer.close();
}
 
开发者ID:europeana,项目名称:search,代码行数:27,代码来源:TestMultiTermConstantScore.java

示例6: createDocument

import org.apache.lucene.document.FieldType; //导入方法依赖的package包/类
public static Document createDocument(int n, int numFields) {
  StringBuilder sb = new StringBuilder();
  Document doc = new Document();
  sb.append("a");
  sb.append(n);
  FieldType customType2 = new FieldType(TextField.TYPE_STORED);
  customType2.setTokenized(false);
  customType2.setOmitNorms(true);
  FieldType customType3 = new FieldType();
  customType3.setStored(true);
  doc.add(new TextField("field1", sb.toString(), Field.Store.YES));
  doc.add(new Field("fielda", sb.toString(), customType2));
  doc.add(new Field("fieldb", sb.toString(), customType3));
  sb.append(" b");
  sb.append(n);
  for (int i = 1; i < numFields; i++) {
    doc.add(new TextField("field" + (i+1), sb.toString(), Field.Store.YES));
  }
  return doc;
}
 
开发者ID:europeana,项目名称:search,代码行数:21,代码来源:TestDirectoryReaderReopen.java

示例7: Document

import org.apache.lucene.document.FieldType; //导入方法依赖的package包/类
public static Document Document(File f)
     throws java.io.FileNotFoundException {
  Document doc = new Document();
  doc.add(new StoredField("path", f.getPath()));
  doc.add(new StoredField("modified",
                    DateTools.timeToString(f.lastModified(), DateTools.Resolution.MINUTE)));
  
  //create new FieldType to store term positions (TextField is not sufficiently configurable)
  FieldType ft = new FieldType();
  ft.setIndexOptions(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS);
  ft.setTokenized(true);
  ft.setStoreTermVectors(true);
  ft.setStoreTermVectorPositions(true);
  Field contentsField = new Field("contents", new FileReader(f), ft);

  doc.add(contentsField);
  return doc;
}
 
开发者ID:semanticvectors,项目名称:semanticvectors,代码行数:19,代码来源:FilePositionDoc.java

示例8: filter

import org.apache.lucene.document.FieldType; //导入方法依赖的package包/类
@Override
public boolean filter(FullConcept concept) {
    //index
    Document doc = new Document();

    /** The customized field type for contents field */
    FieldType contentFieldType = new FieldType();
    contentFieldType.setIndexed(true);
    contentFieldType.setStored(true);
    contentFieldType.setStoreTermVectors(true);
    contentFieldType.setTokenized(true);

    doc.add(new Field("contents", concept.getTitle() + "\n" + concept.getPlainContent(), contentFieldType));
    doc.add(new StringField("id", Integer.toString(concept.getId()), Field.Store.YES));
    doc.add(new StringField("outId", concept.getOutId(), Field.Store.YES));
    doc.add(new Field("title", concept.getTitle(), contentFieldType));

    try {
        writer.addDocument(doc);
    } catch (IOException e) {
        e.printStackTrace();
    }

    return true;
}
 
开发者ID:iamxiatian,项目名称:wikit,代码行数:26,代码来源:IndexConceptVisitor.java

示例9: getAllFieldType

import org.apache.lucene.document.FieldType; //导入方法依赖的package包/类
private FieldType getAllFieldType() {
    FieldType ft = new FieldType();
    ft.setIndexOptions(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS);
    ft.setTokenized(true);
    ft.freeze();
    return ft;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:8,代码来源:SimpleAllTests.java

示例10: getDoc

import org.apache.lucene.document.FieldType; //导入方法依赖的package包/类
@Override
public List<Document> getDoc(List<IfcProductRecordText> items) {
	
	List<Document> docs = new ArrayList<Document>();  
       FieldType storedType = new FieldType();  
       storedType.setIndexed(true);  
       storedType.setStored(true);  
       storedType.setTokenized(true); 
       
       FieldType unTokeType = new FieldType();
       unTokeType.setIndexed(true);  
       unTokeType.setStored(true);   
       unTokeType.setTokenized(false); 
       
       for (IfcProductRecordText record : items) {
       	Document doc = new Document();
       	
       	Field oid = genStringFieldCheckNull(Key_Oid, record.getOid(), unTokeType);
       	Field type = genStringFieldCheckNull(Key_Type, record.getType(), storedType);
       	Field name = genStringFieldCheckNull(Key_Name, record.getName(), storedType);
       	Field detail = genStringFieldCheckNull(Key_Detail, record.getDetail(), storedType);
       	
       	doc.add(oid);
       	doc.add(type);
       	doc.add(name);
       	doc.add(detail);
       	
       	docs.add(doc);
       }
	return docs;
	
	
}
 
开发者ID:shenan4321,项目名称:BIMplatform,代码行数:34,代码来源:IfcProductRecordTextSearch.java

示例11: createFieldType

import org.apache.lucene.document.FieldType; //导入方法依赖的package包/类
private FieldType createFieldType() {
	FieldType ft = new FieldType();
	ft.setIndexed(true);
	ft.setTokenized(true);
	ft.setOmitNorms(true);
	ft.freeze();
	return ft;
}
 
开发者ID:arne-cl,项目名称:fangorn,代码行数:9,代码来源:CreateIndex.java

示例12: getFieldType

import org.apache.lucene.document.FieldType; //导入方法依赖的package包/类
private static FieldType getFieldType() {
	FieldType ft = new FieldType();
	ft.setIndexed(true);
	ft.setTokenized(true);
	ft.setOmitNorms(true);
	ft.freeze();
	return ft;
}
 
开发者ID:arne-cl,项目名称:fangorn,代码行数:9,代码来源:IndexTestCase.java

示例13: index

import org.apache.lucene.document.FieldType; //导入方法依赖的package包/类
public void index() throws CorruptIndexException,
    LockObtainFailedException, IOException {
    Directory dir = FSDirectory.open(indexDirectory);
    Analyzer analyzer = new StandardAnalyzer(Version.LUCENE_41,StandardAnalyzer.STOP_WORDS_SET);
    IndexWriterConfig iwc = new IndexWriterConfig(Version.LUCENE_41, analyzer);
    if (indexDirectory.exists()) {
        iwc.setOpenMode(IndexWriterConfig.OpenMode.CREATE);
    } else {
        iwc.setOpenMode(IndexWriterConfig.OpenMode.CREATE_OR_APPEND);
    }
    IndexWriter writer = new IndexWriter(dir, iwc);
    for (File f : sourceDirectory.listFiles()) {
        System.out.println("Indexing Document  "+f.getName());
        Document doc = new Document();
        FieldType fieldType = new FieldType();
        fieldType.setIndexed(true);
        fieldType.setIndexOptions(FieldInfo.IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS);
        fieldType.setStored(true);
        fieldType.setStoreTermVectors(true);
        fieldType.setTokenized(true);
        Field contentField = new Field(fieldName, ExtractText(f), fieldType);
        doc.add(contentField);
        doc.add(new TextField("FileName", f.getName(), Field.Store.YES));
        doc.add(new TextField("FilePath",f.getCanonicalPath(),Field.Store.YES));
        writer.addDocument(doc);
    }
    writer.close();
}
 
开发者ID:unsw-cse-soc,项目名称:Data-curation-API,代码行数:29,代码来源:Index.java

示例14: getNotTokenizedFieldType

import org.apache.lucene.document.FieldType; //导入方法依赖的package包/类
/**
 * Ritorna un tipo field, stored, not tokenized e indexed
 *
 * @return field type utilizzabili per chiavi o elementi che non si vogliono
 * tokenizzare
 */
public static FieldType getNotTokenizedFieldType() {
    FieldType keywordFieldType = new FieldType();
    keywordFieldType.setStored(true);
    keywordFieldType.setTokenized(false);
    keywordFieldType.setIndexOptions(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS);
    return keywordFieldType;
}
 
开发者ID:fiohol,项目名称:theSemProject,代码行数:14,代码来源:IndexManager.java

示例15: createFieldType

import org.apache.lucene.document.FieldType; //导入方法依赖的package包/类
private static FieldType createFieldType(boolean tokenized) {
    FieldType answer = new FieldType();
    //answer.setIndexed(true);
    answer.setStored(true);
    answer.setTokenized(tokenized);

    // freeze the answer so that it becomes immutable
    answer.freeze();

    return answer;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:12,代码来源:LuceneIndexer.java


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