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


Java IntField类代码示例

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


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

示例1: addContentField

import org.apache.lucene.document.IntField; //导入依赖的package包/类
protected void addContentField(int pageNo, JRPrintText element) throws IOException {
	String allText;
	JRStyledText styledText = getStyledText(element);
	if (styledText == null) {
		allText = "";
	} else {
		allText = styledText.getText();
	}

	if (allText != null && allText.length() > 0) {
		Field tf = new Field(CONTENT_FIELD, allText, fieldType);
		Document doc = new Document();
		doc.add(new IntField("pageNo", pageNo, Field.Store.YES));

		PrintElementId peid = PrintElementId.forElement(element);
		doc.add(new StringField("uid", peid.toString(), Field.Store.YES));

		displayTokens(allText, peid.toString());

		doc.add(tf);
		writer.addDocument(doc);
	}

}
 
开发者ID:TIBCOSoftware,项目名称:jasperreports,代码行数:25,代码来源:LuceneUtil.java

示例2: createIndexQ

import org.apache.lucene.document.IntField; //导入依赖的package包/类
public static void createIndexQ(List<CQAResult> QASetList, Directory dir) {
    System.out.println("Creating Questions Index");
    IndexWriterConfig iwc = new IndexWriterConfig(ANALYZER.getVersion(), ANALYZER);
    iwc.setOpenMode(IndexWriterConfig.OpenMode.CREATE);
    try {
        IndexWriter writer = new IndexWriter(dir, iwc);
        int id = 0; //XXX seq_id
        for (CQAResult qaSet : QASetList) {
            Document doc = new Document();
            if (qaSet.subject == null) {
                id++;
                continue;
            }
            doc.add(new IntField(QID, id++, Field.Store.YES));
            doc.add(new TextField(BEST_ANSWER_FIELD, qaSet.subject, Field.Store.NO));
            doc.add(new TextField(Q_DESCRIPTION, qaSet.content, Field.Store.NO));
            writer.addDocument(doc);
        }
        writer.close();
    } catch (IOException e) {
        e.printStackTrace();
    }
}
 
开发者ID:oaqa,项目名称:LiveQA,代码行数:24,代码来源:QaPairIndex.java

示例3: buildDucument

import org.apache.lucene.document.IntField; //导入依赖的package包/类
private Document buildDucument(ShopDTO shopDTO){
    Document document = new Document();

    document.add(new IntField(ShopDTO.ShopParam.SHOP_ID, shopDTO.getShopid(), Field.Store.YES));
    document.add(new TextField(ShopDTO.ShopParam.SHOP_NAME, shopDTO.getShopname(), Field.Store.YES));
    //document.add(new StringField(ShopDTO.ShopParam.CITY_ID, shopDTO.getCityid()+"", Field.Store.YES));
    document.add(new IntField(ShopDTO.ShopParam.CITY_ID, shopDTO.getCityid(), Field.Store.YES));
    if (shopDTO.getTaglist()!=null && shopDTO.getTaglist().size()>0) {
        for (int tagid: shopDTO.getTaglist()) {
            document.add(new IntField(ShopDTO.ShopParam.TAG_ID, tagid, Field.Store.YES));
        }
    }
    document.add(new IntField(ShopDTO.ShopParam.SCORE, shopDTO.getScore(), LuceneUtil.INT_FIELD_TYPE_STORED_SORTED));
    document.add(new IntField(ShopDTO.ShopParam.HOT_SCORE, shopDTO.getHotscore(), LuceneUtil.INT_FIELD_TYPE_STORED_SORTED));

    return document;
}
 
开发者ID:xuxueli,项目名称:xxl-search,代码行数:18,代码来源:LuceneSearchServiceImpl.java

示例4: resolveField

import org.apache.lucene.document.IntField; //导入依赖的package包/类
/**
 * resolve field convertable premitive type
 *
 * premitive type
 * byte, short, int, long, float, double, char, boolean
 *
 * @param type field type
 * @return lucene field type
 */
private Class<? extends Field> resolveField(Type type) {
	if(type == String.class) {
		return StringField.class;
	} else if (type == Double.class || type == double.class) {
		return DoubleField.class;
	} else if(type == Float.class || type == float.class) {
		return FloatField.class;
	} else if(type == Integer.class || type == int.class ||
			type == Short.class || type == short.class ||
			type == Boolean.class || type == boolean.class ||
			type == Byte.class || type == byte.class ||
			type == Character.class || type == char.class) {
		return IntField.class;
	} else if(type == Long.class || type == long.class) {
		return LongField.class;
	}
	return null;
}
 
开发者ID:ksgwr,项目名称:LuceneDB,代码行数:28,代码来源:LuceneObjectValuesDB.java

示例5: simpleTest

import org.apache.lucene.document.IntField; //导入依赖的package包/类
@Test
public void simpleTest() throws IOException {
	LuceneValuesDB valuesDB = new LuceneValuesDB();
	URL testPath = LuceneValuesDB.class.getResource("test.csv");

	@SuppressWarnings("unchecked")
	UserDefineDocumentCreator creator = new UserDefineDocumentCreator(new Class[] {
			IntField.class,
			StringField.class,
			FloatField.class,
			TextField.class
	}, new String[] {
			"docNum",
			"docType",
			"score",
			"text"
	});

	valuesDB.open(new File(testPath.getFile()), new CSVParser(), creator);

	assertEquals(1, valuesDB.search("docNum", 0).length);
	assertEquals(1, valuesDB.search("docType", "a").length);
	assertEquals(2, valuesDB.search("score", "0.1").length);
	assertEquals(1, valuesDB.search("text", "this is a pen").length);
}
 
开发者ID:ksgwr,项目名称:LuceneDB,代码行数:26,代码来源:UserDefineDocumentCreatorTest.java

示例6: DocState

import org.apache.lucene.document.IntField; //导入依赖的package包/类
public DocState(boolean reuseFields, FieldType ft, FieldType bodyFt) {

      this.reuseFields = reuseFields;
      
      if (reuseFields) {
        fields =  new HashMap<>();
        numericFields = new HashMap<>();
        
        // Initialize the map with the default fields.
        fields.put(BODY_FIELD, new Field(BODY_FIELD, "", bodyFt));
        fields.put(TITLE_FIELD, new Field(TITLE_FIELD, "", ft));
        fields.put(DATE_FIELD, new Field(DATE_FIELD, "", ft));
        fields.put(ID_FIELD, new StringField(ID_FIELD, "", Field.Store.YES));
        fields.put(NAME_FIELD, new Field(NAME_FIELD, "", ft));

        numericFields.put(DATE_MSEC_FIELD, new LongField(DATE_MSEC_FIELD, 0L, Field.Store.NO));
        numericFields.put(TIME_SEC_FIELD, new IntField(TIME_SEC_FIELD, 0, Field.Store.NO));
        
        doc = new Document();
      } else {
        numericFields = null;
        fields = null;
        doc = null;
      }
    }
 
开发者ID:europeana,项目名称:search,代码行数:26,代码来源:DocMaker.java

示例7: newSampleDocument

import org.apache.lucene.document.IntField; //导入依赖的package包/类
private Document newSampleDocument(int id, Shape... shapes) {
  Document doc = new Document();
  doc.add(new IntField("id", id, Field.Store.YES));
  //Potentially more than one shape in this field is supported by some
  // strategies; see the javadocs of the SpatialStrategy impl to see.
  for (Shape shape : shapes) {
    for (IndexableField f : strategy.createIndexableFields(shape)) {
      doc.add(f);
    }
    //store it too; the format is up to you
    //  (assume point in this example)
    Point pt = (Point) shape;
    doc.add(new StoredField(strategy.getFieldName(), pt.getX()+" "+pt.getY()));
  }

  return doc;
}
 
开发者ID:europeana,项目名称:search,代码行数:18,代码来源:SpatialExample.java

示例8: setUp

import org.apache.lucene.document.IntField; //导入依赖的package包/类
@Override
public void setUp() throws Exception {
  super.setUp();
  dir = newDirectory();
  RandomIndexWriter iw = new RandomIndexWriter(random(), dir);
  int numDocs = TestUtil.nextInt(random(), 2049, 4000);
  for (int i = 0; i < numDocs; i++) {
    Document document = new Document();
    document.add(newTextField("english", English.intToEnglish(i), Field.Store.NO));
    document.add(newTextField("oddeven", (i % 2 == 0) ? "even" : "odd", Field.Store.NO));
    document.add(newStringField("byte", "" + ((byte) random().nextInt()), Field.Store.NO));
    document.add(newStringField("short", "" + ((short) random().nextInt()), Field.Store.NO));
    document.add(new IntField("int", random().nextInt(), Field.Store.NO));
    document.add(new LongField("long", random().nextLong(), Field.Store.NO));

    document.add(new FloatField("float", random().nextFloat(), Field.Store.NO));
    document.add(new DoubleField("double", random().nextDouble(), Field.Store.NO));

    document.add(new NumericDocValuesField("intdocvalues", random().nextInt()));
    document.add(new FloatDocValuesField("floatdocvalues", random().nextFloat()));
    iw.addDocument(document);
  }
  reader = iw.getReader();
  iw.close();
  searcher = newSearcher(reader);
}
 
开发者ID:europeana,项目名称:search,代码行数:27,代码来源:TestExpressionSorts.java

示例9: testIntFieldMinMax

import org.apache.lucene.document.IntField; //导入依赖的package包/类
public void testIntFieldMinMax() throws Exception {
  Directory dir = newDirectory();
  RandomIndexWriter w = new RandomIndexWriter(random(), dir);
  int numDocs = atLeast(100);
  int minValue = Integer.MAX_VALUE;
  int maxValue = Integer.MIN_VALUE;
  for(int i=0;i<numDocs;i++ ){
    Document doc = new Document();
    int num = random().nextInt();
    minValue = Math.min(num, minValue);
    maxValue = Math.max(num, maxValue);
    doc.add(new IntField("field", num, Field.Store.NO));
    w.addDocument(doc);
  }
  
  IndexReader r = w.getReader();
  Terms terms = MultiFields.getTerms(r, "field");
  assertEquals(minValue, NumericUtils.getMinInt(terms));
  assertEquals(maxValue, NumericUtils.getMaxInt(terms));

  r.close();
  w.close();
  dir.close();
}
 
开发者ID:europeana,项目名称:search,代码行数:25,代码来源:TestTerms.java

示例10: createDoc_Tour

import org.apache.lucene.document.IntField; //导入依赖的package包/类
private static void createDoc_Tour(	final IndexWriter indexWriter,
									final long tourId,
									final String title,
									final String description,
									final long time) throws IOException {

	final Document doc = new Document();

	doc.add(new IntField(SEARCH_FIELD_DOC_SOURCE, DOC_SOURCE_TOUR, Store.YES));

	doc.add(new LongField(SEARCH_FIELD_TOUR_ID, tourId, Store.YES));
	doc.add(new LongField(SEARCH_FIELD_TIME, time, createFieldType_Long()));

	if (title != null) {
		doc.add(new Field(SEARCH_FIELD_TITLE, title, createFieldType_Text()));
	}

	if (description != null) {
		doc.add(new Field(SEARCH_FIELD_DESCRIPTION, description, createFieldType_Text()));
	}

	indexWriter.addDocument(doc);
}
 
开发者ID:wolfgang-ch,项目名称:mytourbook,代码行数:24,代码来源:FTSearchManager.java

示例11: DocState

import org.apache.lucene.document.IntField; //导入依赖的package包/类
public DocState(boolean reuseFields, FieldType ft, FieldType bodyFt) {

      this.reuseFields = reuseFields;
      
      if (reuseFields) {
        fields =  new HashMap<String,Field>();
        numericFields = new HashMap<String,Field>();
        
        // Initialize the map with the default fields.
        fields.put(BODY_FIELD, new Field(BODY_FIELD, "", bodyFt));
        fields.put(TITLE_FIELD, new Field(TITLE_FIELD, "", ft));
        fields.put(DATE_FIELD, new Field(DATE_FIELD, "", ft));
        fields.put(ID_FIELD, new StringField(ID_FIELD, "", Field.Store.YES));
        fields.put(NAME_FIELD, new Field(NAME_FIELD, "", ft));

        numericFields.put(DATE_MSEC_FIELD, new LongField(DATE_MSEC_FIELD, 0L, Field.Store.NO));
        numericFields.put(TIME_SEC_FIELD, new IntField(TIME_SEC_FIELD, 0, Field.Store.NO));
        
        doc = new Document();
      } else {
        numericFields = null;
        fields = null;
        doc = null;
      }
    }
 
开发者ID:pkarmstr,项目名称:NYBC,代码行数:26,代码来源:DocMaker.java

示例12: getListOfUnmodifiedFieldsFromIAView

import org.apache.lucene.document.IntField; //导入依赖的package包/类
private List<Field> getListOfUnmodifiedFieldsFromIAView(InformationAssetView iaView) {
List<Field> listOfUnmodifiedFields = new ArrayList<Field>();
if (iaView.getCATDOCREF() != null) {
    listOfUnmodifiedFields.add(new TextField(InformationAssetViewFields.CATDOCREF.toString(), iaView
	    .getCATDOCREF(), Field.Store.NO));
}
if (iaView.getDESCRIPTION() != null) {
    listOfUnmodifiedFields.add(new TextField(InformationAssetViewFields.DESCRIPTION.toString(), iaView
	    .getDESCRIPTION(), Field.Store.NO));
}
if (iaView.getTITLE() != null) {
    listOfUnmodifiedFields.add(new TextField(InformationAssetViewFields.TITLE.toString(), iaView.getTITLE(),
	    Field.Store.NO));
}
if (iaView.getSOURCE() != null) {
    listOfUnmodifiedFields.add(new IntField(InformationAssetViewFields.SOURCE.toString(), Integer
	    .parseInt(iaView.getSOURCE()), Field.Store.NO));
}
return listOfUnmodifiedFields;
   }
 
开发者ID:nationalarchives,项目名称:taxonomy,代码行数:21,代码来源:InMemoryIAViewRepository.java

示例13: process

import org.apache.lucene.document.IntField; //导入依赖的package包/类
@Override
public void process(JCas jCas) throws AnalysisEngineProcessException {
    int pmid = BlueCasUtil.getHeaderIntDocId(jCas);
    if (!BlueCasUtil.isEmptyText(jCas)) {
        // System.out.println("indexing:: " + pmid);
        Document doc = new Document();
        doc.add(new IntField(PMID_FIELD, pmid, Store.YES));
        doc.add(new TextField(CONTENT_FIELD, jCas.getDocumentText(),
                Store.YES));
        doc.add(new TextField(TITLE_FIELD, getTitle(jCas), Store.YES));
        try {
            indexWriter.addDocument(doc);
        } catch (IOException e) {
            throw new AnalysisEngineProcessException(e);
        }
    }
}
 
开发者ID:BlueBrain,项目名称:bluima,代码行数:18,代码来源:Txt2PubmedIdIndexer.java

示例14: configure

import org.apache.lucene.document.IntField; //导入依赖的package包/类
@Override
public void configure(String fieldNameForThisInstance, Map<String, String> properties, Configuration configuration) {
  String precisionStepStr = properties.get(NUMERIC_PRECISION_STEP);
  if (precisionStepStr != null) {
    _precisionStep = Integer.parseInt(precisionStepStr);
    _typeStored = new FieldType(IntField.TYPE_STORED);
    _typeStored.setNumericPrecisionStep(_precisionStep);
    _typeStored.freeze();
    _typeNotStored = new FieldType(IntField.TYPE_NOT_STORED);
    _typeNotStored.setNumericPrecisionStep(_precisionStep);
    _typeNotStored.freeze();
  } else {
    _typeStored = IntField.TYPE_STORED;
    _typeNotStored = IntField.TYPE_NOT_STORED;
  }
}
 
开发者ID:apache,项目名称:incubator-blur,代码行数:17,代码来源:IntFieldTypeDefinition.java

示例15: addLine

import org.apache.lucene.document.IntField; //导入依赖的package包/类
public void addLine(int lineNumber, String text) {
	if (loadExistingIndex) {
		throw new IllegalStateException("Cannot add lines to an already existing index.");
	}
	Document luceneDocument = new Document();
	luceneDocument.add(new IntField(LINE_NUMBER, (int) (lineNumber - 1), Field.Store.YES));
	luceneDocument.add(new TextField(LINE_TEXT, text, Field.Store.NO));

	try {
		synchronized (this) {
			luceneIndexWriter.addDocument(luceneDocument);
		}
	} catch (IOException e) {
		logger.warn(e.getMessage(), e);
	}
}
 
开发者ID:NimbleGen,项目名称:bioinformatics,代码行数:17,代码来源:TextSearchIndex.java


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