Package org.apache.lucene.document

Examples of org.apache.lucene.document.NumericField


    @Test public void intFieldDataTests() throws Exception {
        Directory dir = new RAMDirectory();
        IndexWriter indexWriter = new IndexWriter(dir, new IndexWriterConfig(Lucene.VERSION, Lucene.STANDARD_ANALYZER));

        indexWriter.addDocument(doc()
                .add(new NumericField("svalue").setIntValue(4))
                .add(new NumericField("mvalue").setIntValue(104))
                .build());

        indexWriter.addDocument(doc()
                .add(new NumericField("svalue").setIntValue(3))
                .add(new NumericField("mvalue").setIntValue(104))
                .add(new NumericField("mvalue").setIntValue(105))
                .build());

        indexWriter.addDocument(doc()
                .add(new NumericField("svalue").setIntValue(7))
                .build());

        indexWriter.addDocument(doc()
                .add(new NumericField("mvalue").setIntValue(102))
                .build());

        indexWriter.addDocument(doc()
                .add(new NumericField("svalue").setIntValue(4))
                .build());

        IndexReader reader = IndexReader.open(indexWriter, true);

        IntFieldData sFieldData = IntFieldData.load(reader, "svalue");
View Full Code Here


    @Test public void intFieldDataTests() throws Exception {
        Directory dir = new RAMDirectory();
        IndexWriter indexWriter = new IndexWriter(dir, new IndexWriterConfig(Lucene.VERSION, Lucene.STANDARD_ANALYZER));

        indexWriter.addDocument(doc()
                .add(new NumericField("svalue").setIntValue(4))
                .add(new NumericField("mvalue").setIntValue(104))
                .build());

        indexWriter.addDocument(doc()
                .add(new NumericField("svalue").setIntValue(3))
                .add(new NumericField("mvalue").setIntValue(104))
                .add(new NumericField("mvalue").setIntValue(105))
                .build());

        indexWriter.addDocument(doc()
                .add(new NumericField("svalue").setIntValue(7))
                .build());

        indexWriter.addDocument(doc()
                .add(new NumericField("mvalue").setIntValue(102))
                .build());

        indexWriter.addDocument(doc()
                .add(new NumericField("svalue").setIntValue(4))
                .build());

        IndexReader reader = IndexReader.open(indexWriter, true);

        ShortFieldData sFieldData = ShortFieldData.load(reader, "svalue");
View Full Code Here

    @Test public void intFieldDataTests() throws Exception {
        Directory dir = new RAMDirectory();
        IndexWriter indexWriter = new IndexWriter(dir, new IndexWriterConfig(Lucene.VERSION, Lucene.STANDARD_ANALYZER));

        indexWriter.addDocument(doc()
                .add(new NumericField("svalue").setLongValue(4))
                .add(new NumericField("mvalue").setLongValue(104))
                .build());

        indexWriter.addDocument(doc()
                .add(new NumericField("svalue").setLongValue(3))
                .add(new NumericField("mvalue").setLongValue(104))
                .add(new NumericField("mvalue").setLongValue(105))
                .build());

        indexWriter.addDocument(doc()
                .add(new NumericField("svalue").setLongValue(7))
                .build());

        indexWriter.addDocument(doc()
                .add(new NumericField("mvalue").setLongValue(102))
                .build());

        indexWriter.addDocument(doc()
                .add(new NumericField("svalue").setLongValue(4))
                .build());

        IndexReader reader = IndexReader.open(indexWriter, true);

        LongFieldData sFieldData = LongFieldData.load(reader, "svalue");
View Full Code Here

    @Test public void intFieldDataTests() throws Exception {
        Directory dir = new RAMDirectory();
        IndexWriter indexWriter = new IndexWriter(dir, new IndexWriterConfig(Lucene.VERSION, Lucene.STANDARD_ANALYZER));

        indexWriter.addDocument(doc()
                .add(new NumericField("svalue").setDoubleValue(4))
                .add(new NumericField("mvalue").setDoubleValue(104))
                .build());

        indexWriter.addDocument(doc()
                .add(new NumericField("svalue").setDoubleValue(3))
                .add(new NumericField("mvalue").setDoubleValue(104))
                .add(new NumericField("mvalue").setDoubleValue(105))
                .build());

        indexWriter.addDocument(doc()
                .add(new NumericField("svalue").setDoubleValue(7))
                .build());

        indexWriter.addDocument(doc()
                .add(new NumericField("mvalue").setDoubleValue(102))
                .build());

        indexWriter.addDocument(doc()
                .add(new NumericField("svalue").setDoubleValue(4))
                .build());

        IndexReader reader = IndexReader.open(indexWriter, true);

        DoubleFieldData sFieldData = DoubleFieldData.load(reader, "svalue");
View Full Code Here

     */
    private Document createMessageDocument(final MailboxSession session, final Message<?> membership) throws MailboxException{
        final Document doc = new Document();
        // TODO: Better handling
        doc.add(new Field(MAILBOX_ID_FIELD, membership.getMailboxId().toString().toUpperCase(Locale.ENGLISH), Store.YES, Index.NOT_ANALYZED));
        doc.add(new NumericField(UID_FIELD,Store.YES, true).setLongValue(membership.getUid()));
       
        // create an unqiue key for the document which can be used later on updates to find the document
        doc.add(new Field(ID_FIELD, membership.getMailboxId().toString().toUpperCase(Locale.ENGLISH) +"-" + Long.toString(membership.getUid()), Store.YES, Index.NOT_ANALYZED));

        doc.add(new Field(INTERNAL_DATE_FIELD_YEAR_RESOLUTION, DateTools.dateToString(membership.getInternalDate(), DateTools.Resolution.YEAR), Store.NO, Index.NOT_ANALYZED));
        doc.add(new Field(INTERNAL_DATE_FIELD_MONTH_RESOLUTION, DateTools.dateToString(membership.getInternalDate(), DateTools.Resolution.MONTH), Store.NO, Index.NOT_ANALYZED));
        doc.add(new Field(INTERNAL_DATE_FIELD_DAY_RESOLUTION, DateTools.dateToString(membership.getInternalDate(), DateTools.Resolution.DAY), Store.NO, Index.NOT_ANALYZED));
        doc.add(new Field(INTERNAL_DATE_FIELD_HOUR_RESOLUTION, DateTools.dateToString(membership.getInternalDate(), DateTools.Resolution.HOUR), Store.NO, Index.NOT_ANALYZED));
        doc.add(new Field(INTERNAL_DATE_FIELD_MINUTE_RESOLUTION, DateTools.dateToString(membership.getInternalDate(), DateTools.Resolution.MINUTE), Store.NO, Index.NOT_ANALYZED));
        doc.add(new Field(INTERNAL_DATE_FIELD_SECOND_RESOLUTION, DateTools.dateToString(membership.getInternalDate(), DateTools.Resolution.SECOND), Store.NO, Index.NOT_ANALYZED));
        doc.add(new Field(INTERNAL_DATE_FIELD_MILLISECOND_RESOLUTION, DateTools.dateToString(membership.getInternalDate(), DateTools.Resolution.MILLISECOND), Store.NO, Index.NOT_ANALYZED));

        doc.add(new NumericField(SIZE_FIELD,Store.YES, true).setLongValue(membership.getFullContentOctets()));

        // content handler which will index the headers and the body of the message
        SimpleContentHandler handler = new SimpleContentHandler() {
           

View Full Code Here

     */
    private Document createFlagsDocument(Message<?> message) {
        Document doc = new Document();
        doc.add(new Field(ID_FIELD, "flags-" + message.getMailboxId().toString() +"-" + Long.toString(message.getUid()), Store.YES, Index.NOT_ANALYZED));
        doc.add(new Field(MAILBOX_ID_FIELD, message.getMailboxId().toString(), Store.YES, Index.NOT_ANALYZED));
        doc.add(new NumericField(UID_FIELD,Store.YES, true).setLongValue(message.getUid()));
       
        indexFlags(doc, message.createFlags());
        return doc;
    }
View Full Code Here

    IndexWriter indexWriter2 = new IndexWriter(FSDirectory.open(sortIndex2), new StandardAnalyzer(Version.LUCENE_30),
            true, MaxFieldLength.UNLIMITED);

    Document document = new Document();
    document.add(new Field("text", "abc", Field.Store.YES, Index.NOT_ANALYZED));
    document.add(new NumericField("timesort", Field.Store.YES, false).setLongValue(1234567890123l));
    indexWriter1.addDocument(document);
    indexWriter1.close();

    document = new Document();
    document.add(new Field("text", "abc2", Field.Store.YES, Index.NOT_ANALYZED));
    document.add(new NumericField("timesort", Field.Store.YES, false).setLongValue(1234567890123l));
    indexWriter2.addDocument(document);
    indexWriter2.close();

    DeployClient deployClient = new DeployClient(_miniCluster.getProtocol());
    String indexName = "sortIndex";
View Full Code Here

          // NumericRangeFilter).  This indexes to milli-second resolution, which
          // is often too fine.  You could instead create a number based on
          // year/month/day/hour/minutes/seconds, down the resolution you require.
          // For example the long value 2011021714 would mean
          // February 17, 2011, 2-3 PM.
          NumericField modifiedField = new NumericField("modified");
          modifiedField.setLongValue(file.lastModified());
          doc.add(modifiedField);

          // Add the contents of the file to a field named "contents".  Specify a Reader,
          // so that the text of the file is tokenized and indexed, but not stored.
          // Note that FileReader expects the file to be in UTF-8 encoding.
View Full Code Here

        String date=line.substring(0,endOfDate).trim();
        String content=line.substring(endOfDate).trim();
        org.apache.lucene.document.Document doc =new org.apache.lucene.document.Document();
        doc.add(newField("date",date,Field.Store.YES,Field.Index.ANALYZED));
        doc.add(newField("contents",content,Field.Store.YES,Field.Index.ANALYZED));
        NumericField numericField = new NumericField("date2");
        numericField.setIntValue(Integer.valueOf(date));
        doc.add(numericField);
        writer.addDocument(doc);
        line=d.readLine();
      }     
      d.close();
View Full Code Here

        if (groupValue.group != null) {
          doc.add(newField("group", groupValue.group, Field.Index.NOT_ANALYZED));
        }
        doc.add(newField("sort1", groupValue.sort1, Field.Index.NOT_ANALYZED));
        doc.add(newField("sort2", groupValue.sort2, Field.Index.NOT_ANALYZED));
        doc.add(new NumericField("id").setIntValue(groupValue.id));
        doc.add(newField("content", groupValue.content, Field.Index.ANALYZED));
        //System.out.println("TEST:     doc content=" + groupValue.content + " group=" + (groupValue.group == null ? "null" : groupValue.group.utf8ToString()) + " sort1=" + groupValue.sort1.utf8ToString() + " id=" + groupValue.id);
      }
      // So we can pull filter marking last doc in block:
      final Field groupEnd = newField("groupend", "x", Field.Index.NOT_ANALYZED);
View Full Code Here

TOP

Related Classes of org.apache.lucene.document.NumericField

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.