本文整理汇总了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;
}
示例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();
}
示例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);
}
示例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;
}
}
示例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();
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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();
}
示例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;
}
示例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;
}