本文整理汇总了Java中org.apache.lucene.document.FieldType.setIndexed方法的典型用法代码示例。如果您正苦于以下问题:Java FieldType.setIndexed方法的具体用法?Java FieldType.setIndexed怎么用?Java FieldType.setIndexed使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.lucene.document.FieldType
的用法示例。
在下文中一共展示了FieldType.setIndexed方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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();
}
示例2: testAreaValueSource
import org.apache.lucene.document.FieldType; //导入方法依赖的package包/类
public void testAreaValueSource() throws IOException {
setupGeo();
//test we can disable indexed for this test
BBoxStrategy bboxStrategy = (BBoxStrategy) strategy;
if (random().nextBoolean()) {
FieldType fieldType = new FieldType(bboxStrategy.getFieldType());
fieldType.setIndexed(false);
bboxStrategy.setFieldType(fieldType);
}
adoc("100", ctx.makeRectangle(0, 20, 40, 80));
adoc("999", (Shape) null);
commit();
checkValueSource(new ShapeAreaValueSource(bboxStrategy.makeShapeValueSource(), ctx, false),
new float[]{800f, 0f}, 0f);
checkValueSource(new ShapeAreaValueSource(bboxStrategy.makeShapeValueSource(), ctx, true),//geo
new float[]{391.93f, 0f}, 0.01f);
}
示例3: 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;
}
}
示例4: index
import org.apache.lucene.document.FieldType; //导入方法依赖的package包/类
public void index(Item item) throws IOException {
String id = item.getId();
String text = item.getText();
long publicationTIme = item.getPublicationTime();
Document document = new Document();
Field idField = new StringField("id", id, Store.YES);
document.add(idField);
FieldType fieldType = new FieldType();
fieldType.setStored(true);
fieldType.setIndexed(true);
fieldType.setStoreTermVectors(true);
document.add(new Field("text", text, fieldType));
document.add(new LongField("publicationTIme", publicationTIme, LongField.TYPE_STORED));
if(iwriter != null) {
iwriter.addDocument(document);
}
}
示例5: 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;
}
示例6: 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;
}
示例7: 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;
}
示例8: 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;
}
示例9: 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();
}
示例10: setFieldType
import org.apache.lucene.document.FieldType; //导入方法依赖的package包/类
/** Used to customize the indexing options of the 4 number fields, and to a lesser degree the XDL field too. Search
* requires indexed=true, and relevancy requires docValues. If these features aren't needed then disable them.
* {@link FieldType#freeze()} is called on the argument. */
public void setFieldType(FieldType fieldType) {
fieldType.freeze();
this.fieldType = fieldType;
//only double's supported right now
if (fieldType.numericType() != FieldType.NumericType.DOUBLE)
throw new IllegalArgumentException("BBoxStrategy only supports doubles at this time.");
//for xdlFieldType, copy some similar options. Don't do docValues since it isn't needed here.
xdlFieldType = new FieldType(StringField.TYPE_NOT_STORED);
xdlFieldType.setStored(fieldType.stored());
xdlFieldType.setIndexed(fieldType.indexed());
xdlFieldType.freeze();
}
示例11: setUp
import org.apache.lucene.document.FieldType; //导入方法依赖的package包/类
@Override
public void setUp() throws Exception {
super.setUp();
if (strategy instanceof BBoxStrategy && random().nextBoolean()) {//disable indexing sometimes
BBoxStrategy bboxStrategy = (BBoxStrategy)strategy;
final FieldType fieldType = new FieldType(bboxStrategy.getFieldType());
fieldType.setIndexed(false);
bboxStrategy.setFieldType(fieldType);
}
}
示例12: YagoEntityContextScorer
import org.apache.lucene.document.FieldType; //导入方法依赖的package包/类
private YagoEntityContextScorer() {
FieldType ti = new FieldType();
ti.setIndexed(true);
ti.setTokenized(true);
ti.setStored(true);
FieldType n = new FieldType();
n.setStored(true);
n.setIndexed(true);
types = new FieldType[3];
types[0] = n;
types[1] = ti;
ss = new IgnoreTokenStripper(IgnoreTokenStripper.Language.English);
qs = null;
}
示例13: stringField
import org.apache.lucene.document.FieldType; //导入方法依赖的package包/类
@Override
public void stringField(FieldInfo fieldInfo, String value) throws IOException {
final FieldType ft = new FieldType(TextField.TYPE_STORED);
ft.setStoreTermVectors(fieldInfo.hasVectors());
ft.setIndexed(fieldInfo.isIndexed());
ft.setOmitNorms(fieldInfo.omitsNorms());
ft.setIndexOptions(fieldInfo.getIndexOptions());
doc.add(new Field(fieldInfo.name, value, ft));
}
示例14: intField
import org.apache.lucene.document.FieldType; //导入方法依赖的package包/类
@Override
public void intField(FieldInfo fieldInfo, int value) {
FieldType ft = new FieldType(IntField.TYPE_NOT_STORED);
ft.setStored(true);
ft.setIndexed(fieldInfo.isIndexed());
doc.add(new IntField(fieldInfo.name, value, ft));
}
示例15: longField
import org.apache.lucene.document.FieldType; //导入方法依赖的package包/类
@Override
public void longField(FieldInfo fieldInfo, long value) {
FieldType ft = new FieldType(LongField.TYPE_NOT_STORED);
ft.setStored(true);
ft.setIndexed(fieldInfo.isIndexed());
doc.add(new LongField(fieldInfo.name, value, ft));
}