cleanup some test code, rename internal masterDoc to rootDoc
This commit is contained in:
parent
defab5d948
commit
09528610c1
|
@ -395,7 +395,7 @@ public interface Engine extends IndexShardComponent, CloseableComponent {
|
|||
}
|
||||
|
||||
public UidField uidField() {
|
||||
return (UidField) doc.masterDoc().getFieldable(UidFieldMapper.NAME);
|
||||
return (UidField) doc.rootDoc().getFieldable(UidFieldMapper.NAME);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -485,7 +485,7 @@ public interface Engine extends IndexShardComponent, CloseableComponent {
|
|||
}
|
||||
|
||||
public UidField uidField() {
|
||||
return (UidField) doc.masterDoc().getFieldable(UidFieldMapper.NAME);
|
||||
return (UidField) doc.rootDoc().getFieldable(UidFieldMapper.NAME);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -81,7 +81,7 @@ public class ParsedDocument {
|
|||
return this.routing;
|
||||
}
|
||||
|
||||
public Document masterDoc() {
|
||||
public Document rootDoc() {
|
||||
return documents.get(documents.size() - 1);
|
||||
}
|
||||
|
||||
|
|
|
@ -306,7 +306,7 @@ public class PercolatorExecutor extends AbstractIndexComponent {
|
|||
final CustomMemoryIndex memoryIndex = new CustomMemoryIndex();
|
||||
|
||||
// TODO: This means percolation does not support nested docs...
|
||||
for (Fieldable field : request.doc().masterDoc().getFields()) {
|
||||
for (Fieldable field : request.doc().rootDoc().getFields()) {
|
||||
if (!field.isIndexed()) {
|
||||
continue;
|
||||
}
|
||||
|
@ -321,7 +321,7 @@ public class PercolatorExecutor extends AbstractIndexComponent {
|
|||
Reader reader = field.readerValue();
|
||||
if (reader != null) {
|
||||
try {
|
||||
memoryIndex.addField(field.name(), request.doc().analyzer().reusableTokenStream(field.name(), reader), field.getBoost() * request.doc().masterDoc().getBoost());
|
||||
memoryIndex.addField(field.name(), request.doc().analyzer().reusableTokenStream(field.name(), reader), field.getBoost() * request.doc().rootDoc().getBoost());
|
||||
} catch (IOException e) {
|
||||
throw new MapperParsingException("Failed to analyze field [" + field.name() + "]", e);
|
||||
}
|
||||
|
@ -329,7 +329,7 @@ public class PercolatorExecutor extends AbstractIndexComponent {
|
|||
String value = field.stringValue();
|
||||
if (value != null) {
|
||||
try {
|
||||
memoryIndex.addField(field.name(), request.doc().analyzer().reusableTokenStream(field.name(), new FastStringReader(value)), field.getBoost() * request.doc().masterDoc().getBoost());
|
||||
memoryIndex.addField(field.name(), request.doc().analyzer().reusableTokenStream(field.name(), new FastStringReader(value)), field.getBoost() * request.doc().rootDoc().getBoost());
|
||||
} catch (IOException e) {
|
||||
throw new MapperParsingException("Failed to analyze field [" + field.name() + "]", e);
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@ import org.apache.lucene.document.Document;
|
|||
import org.apache.lucene.document.Field;
|
||||
import org.apache.lucene.index.IndexReader;
|
||||
import org.apache.lucene.index.IndexWriter;
|
||||
import org.apache.lucene.index.IndexWriterConfig;
|
||||
import org.apache.lucene.index.Term;
|
||||
import org.apache.lucene.search.IndexSearcher;
|
||||
import org.apache.lucene.search.TopDocs;
|
||||
|
@ -69,7 +70,7 @@ public class SimpleAllTests {
|
|||
|
||||
@Test public void testSimpleAllNoBoost() throws Exception {
|
||||
Directory dir = new RAMDirectory();
|
||||
IndexWriter indexWriter = new IndexWriter(dir, Lucene.STANDARD_ANALYZER, true, IndexWriter.MaxFieldLength.UNLIMITED);
|
||||
IndexWriter indexWriter = new IndexWriter(dir, new IndexWriterConfig(Lucene.VERSION, Lucene.STANDARD_ANALYZER));
|
||||
|
||||
Document doc = new Document();
|
||||
doc.add(new Field("_id", "1", Field.Store.YES, Field.Index.NO));
|
||||
|
@ -91,7 +92,7 @@ public class SimpleAllTests {
|
|||
|
||||
indexWriter.addDocument(doc);
|
||||
|
||||
IndexReader reader = indexWriter.getReader();
|
||||
IndexReader reader = IndexReader.open(indexWriter, true);
|
||||
IndexSearcher searcher = new IndexSearcher(reader);
|
||||
|
||||
TopDocs docs = searcher.search(new AllTermQuery(new Term("_all", "else")), 10);
|
||||
|
@ -111,7 +112,7 @@ public class SimpleAllTests {
|
|||
|
||||
@Test public void testSimpleAllWithBoost() throws Exception {
|
||||
Directory dir = new RAMDirectory();
|
||||
IndexWriter indexWriter = new IndexWriter(dir, Lucene.STANDARD_ANALYZER, true, IndexWriter.MaxFieldLength.UNLIMITED);
|
||||
IndexWriter indexWriter = new IndexWriter(dir, new IndexWriterConfig(Lucene.VERSION, Lucene.STANDARD_ANALYZER));
|
||||
|
||||
Document doc = new Document();
|
||||
doc.add(new Field("_id", "1", Field.Store.YES, Field.Index.NO));
|
||||
|
@ -133,7 +134,7 @@ public class SimpleAllTests {
|
|||
|
||||
indexWriter.addDocument(doc);
|
||||
|
||||
IndexReader reader = indexWriter.getReader();
|
||||
IndexReader reader = IndexReader.open(indexWriter, true);
|
||||
IndexSearcher searcher = new IndexSearcher(reader);
|
||||
|
||||
// this one is boosted. so the second doc is more relevant
|
||||
|
@ -154,7 +155,7 @@ public class SimpleAllTests {
|
|||
|
||||
@Test public void testMultipleTokensAllNoBoost() throws Exception {
|
||||
Directory dir = new RAMDirectory();
|
||||
IndexWriter indexWriter = new IndexWriter(dir, Lucene.STANDARD_ANALYZER, true, IndexWriter.MaxFieldLength.UNLIMITED);
|
||||
IndexWriter indexWriter = new IndexWriter(dir, new IndexWriterConfig(Lucene.VERSION, Lucene.STANDARD_ANALYZER));
|
||||
|
||||
Document doc = new Document();
|
||||
doc.add(new Field("_id", "1", Field.Store.YES, Field.Index.NO));
|
||||
|
@ -176,7 +177,7 @@ public class SimpleAllTests {
|
|||
|
||||
indexWriter.addDocument(doc);
|
||||
|
||||
IndexReader reader = indexWriter.getReader();
|
||||
IndexReader reader = IndexReader.open(indexWriter, true);
|
||||
IndexSearcher searcher = new IndexSearcher(reader);
|
||||
|
||||
TopDocs docs = searcher.search(new AllTermQuery(new Term("_all", "else")), 10);
|
||||
|
@ -206,7 +207,7 @@ public class SimpleAllTests {
|
|||
|
||||
@Test public void testMultipleTokensAllWithBoost() throws Exception {
|
||||
Directory dir = new RAMDirectory();
|
||||
IndexWriter indexWriter = new IndexWriter(dir, Lucene.STANDARD_ANALYZER, true, IndexWriter.MaxFieldLength.UNLIMITED);
|
||||
IndexWriter indexWriter = new IndexWriter(dir, new IndexWriterConfig(Lucene.VERSION, Lucene.STANDARD_ANALYZER));
|
||||
|
||||
Document doc = new Document();
|
||||
doc.add(new Field("_id", "1", Field.Store.YES, Field.Index.NO));
|
||||
|
@ -228,7 +229,7 @@ public class SimpleAllTests {
|
|||
|
||||
indexWriter.addDocument(doc);
|
||||
|
||||
IndexReader reader = indexWriter.getReader();
|
||||
IndexReader reader = IndexReader.open(indexWriter, true);
|
||||
IndexSearcher searcher = new IndexSearcher(reader);
|
||||
|
||||
TopDocs docs = searcher.search(new AllTermQuery(new Term("_all", "else")), 10);
|
||||
|
|
|
@ -21,6 +21,7 @@ package org.elasticsearch.common.lucene.search;
|
|||
|
||||
import org.apache.lucene.index.IndexReader;
|
||||
import org.apache.lucene.index.IndexWriter;
|
||||
import org.apache.lucene.index.IndexWriterConfig;
|
||||
import org.apache.lucene.search.DeletionAwareConstantScoreQuery;
|
||||
import org.apache.lucene.search.IndexSearcher;
|
||||
import org.apache.lucene.store.Directory;
|
||||
|
@ -39,12 +40,12 @@ public class MatchAllDocsFilterTests {
|
|||
|
||||
@Test public void testMatchAllDocsFilter() throws Exception {
|
||||
Directory dir = new RAMDirectory();
|
||||
IndexWriter indexWriter = new IndexWriter(dir, Lucene.STANDARD_ANALYZER, true, IndexWriter.MaxFieldLength.UNLIMITED);
|
||||
IndexWriter indexWriter = new IndexWriter(dir, new IndexWriterConfig(Lucene.VERSION, Lucene.STANDARD_ANALYZER));
|
||||
|
||||
indexWriter.addDocument(doc().add(field("_id", "1")).add(field("text", "lucene")).build());
|
||||
indexWriter.addDocument(doc().add(field("_id", "2")).add(field("text", "lucene release")).build());
|
||||
|
||||
IndexReader reader = indexWriter.getReader();
|
||||
IndexReader reader = IndexReader.open(indexWriter, true);
|
||||
IndexSearcher searcher = new IndexSearcher(reader);
|
||||
|
||||
DeletionAwareConstantScoreQuery query = new DeletionAwareConstantScoreQuery(Queries.MATCH_ALL_FILTER);
|
||||
|
|
|
@ -47,7 +47,7 @@ public class MoreLikeThisQueryTests {
|
|||
indexWriter.addDocument(doc().add(field("_id", "1")).add(field("text", "lucene")).build());
|
||||
indexWriter.addDocument(doc().add(field("_id", "2")).add(field("text", "lucene release")).build());
|
||||
|
||||
IndexReader reader = indexWriter.getReader();
|
||||
IndexReader reader = IndexReader.open(indexWriter, true);
|
||||
IndexSearcher searcher = new IndexSearcher(reader);
|
||||
|
||||
MoreLikeThisQuery mltQuery = new MoreLikeThisQuery("lucene", new String[]{"text"}, Lucene.STANDARD_ANALYZER);
|
||||
|
|
|
@ -22,6 +22,7 @@ package org.elasticsearch.common.lucene.versioned;
|
|||
import org.apache.lucene.document.Document;
|
||||
import org.apache.lucene.index.IndexReader;
|
||||
import org.apache.lucene.index.IndexWriter;
|
||||
import org.apache.lucene.index.IndexWriterConfig;
|
||||
import org.apache.lucene.index.Term;
|
||||
import org.apache.lucene.index.TermDocs;
|
||||
import org.apache.lucene.store.RAMDirectory;
|
||||
|
@ -47,7 +48,7 @@ public class VersionedIndexReaderTests {
|
|||
@BeforeClass public void setUp() throws Exception {
|
||||
versionedMap = new ConcurrentVersionedMapLong();
|
||||
dir = new RAMDirectory();
|
||||
indexWriter = new IndexWriter(dir, Lucene.STANDARD_ANALYZER, true, IndexWriter.MaxFieldLength.UNLIMITED);
|
||||
indexWriter = new IndexWriter(dir, new IndexWriterConfig(Lucene.VERSION, Lucene.STANDARD_ANALYZER));
|
||||
indexWriter.addDocument(doc().add(field("value", "0")).build());
|
||||
indexWriter.addDocument(doc().add(field("value", "1")).build());
|
||||
indexWriter.addDocument(doc().add(field("value", "2")).build());
|
||||
|
@ -66,25 +67,25 @@ public class VersionedIndexReaderTests {
|
|||
TermDocs termDocs;
|
||||
Document doc = indexReader.document(0);
|
||||
|
||||
assertThat(doc.getField("value").stringValue(), equalTo("0"));
|
||||
assertThat(doc.getFieldable("value").stringValue(), equalTo("0"));
|
||||
termDocs = indexReader.termDocs(new Term("value", "0"));
|
||||
assertThat(termDocs.next(), equalTo(true));
|
||||
assertThat(termDocs.next(), equalTo(false));
|
||||
|
||||
doc = indexReader.document(1);
|
||||
assertThat(doc.getField("value").stringValue(), equalTo("1"));
|
||||
assertThat(doc.getFieldable("value").stringValue(), equalTo("1"));
|
||||
termDocs = indexReader.termDocs(new Term("value", "1"));
|
||||
assertThat(termDocs.next(), equalTo(true));
|
||||
assertThat(termDocs.next(), equalTo(false));
|
||||
|
||||
doc = indexReader.document(2);
|
||||
assertThat(doc.getField("value").stringValue(), equalTo("2"));
|
||||
assertThat(doc.getFieldable("value").stringValue(), equalTo("2"));
|
||||
termDocs = indexReader.termDocs(new Term("value", "2"));
|
||||
assertThat(termDocs.next(), equalTo(true));
|
||||
assertThat(termDocs.next(), equalTo(false));
|
||||
|
||||
doc = indexReader.document(3);
|
||||
assertThat(doc.getField("value").stringValue(), equalTo("3"));
|
||||
assertThat(doc.getFieldable("value").stringValue(), equalTo("3"));
|
||||
termDocs = indexReader.termDocs(new Term("value", "3"));
|
||||
assertThat(termDocs.next(), equalTo(true));
|
||||
assertThat(termDocs.next(), equalTo(false));
|
||||
|
|
|
@ -23,6 +23,7 @@ import org.apache.lucene.document.Document;
|
|||
import org.apache.lucene.document.NumericField;
|
||||
import org.apache.lucene.index.IndexReader;
|
||||
import org.apache.lucene.index.IndexWriter;
|
||||
import org.apache.lucene.index.IndexWriterConfig;
|
||||
import org.apache.lucene.search.FieldCache;
|
||||
import org.apache.lucene.store.Directory;
|
||||
import org.apache.lucene.store.RAMDirectory;
|
||||
|
@ -44,7 +45,7 @@ public class LuceneFieldCacheTests {
|
|||
*/
|
||||
@Test public void testTwoFieldSameNameNumericFieldCache() throws Exception {
|
||||
Directory dir = new RAMDirectory();
|
||||
IndexWriter indexWriter = new IndexWriter(dir, Lucene.STANDARD_ANALYZER, true, IndexWriter.MaxFieldLength.UNLIMITED);
|
||||
IndexWriter indexWriter = new IndexWriter(dir, new IndexWriterConfig(Lucene.VERSION, Lucene.STANDARD_ANALYZER));
|
||||
|
||||
Document doc = new Document();
|
||||
NumericField field = new NumericField("int1").setIntValue(1);
|
||||
|
@ -55,7 +56,7 @@ public class LuceneFieldCacheTests {
|
|||
|
||||
indexWriter.addDocument(doc);
|
||||
|
||||
IndexReader reader = indexWriter.getReader();
|
||||
IndexReader reader = IndexReader.open(indexWriter, true);
|
||||
int[] ints = FieldCache.DEFAULT.getInts(reader, "int1");
|
||||
assertThat(ints.length, equalTo(1));
|
||||
assertThat(ints[0], equalTo(2));
|
||||
|
|
|
@ -27,6 +27,7 @@ import org.apache.lucene.document.Fieldable;
|
|||
import org.apache.lucene.document.NumericField;
|
||||
import org.apache.lucene.index.IndexReader;
|
||||
import org.apache.lucene.index.IndexWriter;
|
||||
import org.apache.lucene.index.IndexWriterConfig;
|
||||
import org.apache.lucene.index.Term;
|
||||
import org.apache.lucene.index.TermDocs;
|
||||
import org.apache.lucene.index.TermEnum;
|
||||
|
@ -55,11 +56,11 @@ public class SimpleLuceneTests {
|
|||
|
||||
@Test public void testSortValues() throws Exception {
|
||||
Directory dir = new RAMDirectory();
|
||||
IndexWriter indexWriter = new IndexWriter(dir, Lucene.STANDARD_ANALYZER, true, IndexWriter.MaxFieldLength.UNLIMITED);
|
||||
IndexWriter indexWriter = new IndexWriter(dir, new IndexWriterConfig(Lucene.VERSION, Lucene.STANDARD_ANALYZER));
|
||||
for (int i = 0; i < 10; i++) {
|
||||
indexWriter.addDocument(doc().add(field("str", new String(new char[]{(char) (97 + i), (char) (97 + i)}))).build());
|
||||
}
|
||||
IndexReader reader = indexWriter.getReader();
|
||||
IndexReader reader = IndexReader.open(indexWriter, true);
|
||||
IndexSearcher searcher = new IndexSearcher(reader);
|
||||
TopFieldDocs docs = searcher.search(new MatchAllDocsQuery(), null, 10, new Sort(new SortField("str", SortField.STRING)));
|
||||
for (int i = 0; i < 10; i++) {
|
||||
|
@ -70,30 +71,31 @@ public class SimpleLuceneTests {
|
|||
|
||||
@Test public void testAddDocAfterPrepareCommit() throws Exception {
|
||||
Directory dir = new RAMDirectory();
|
||||
IndexWriter indexWriter = new IndexWriter(dir, Lucene.STANDARD_ANALYZER, true, IndexWriter.MaxFieldLength.UNLIMITED);
|
||||
IndexWriter indexWriter = new IndexWriter(dir, new IndexWriterConfig(Lucene.VERSION, Lucene.STANDARD_ANALYZER));
|
||||
indexWriter.addDocument(doc()
|
||||
.add(field("_id", "1")).build());
|
||||
IndexReader reader = indexWriter.getReader();
|
||||
IndexReader reader = IndexReader.open(indexWriter, true);
|
||||
assertThat(reader.numDocs(), equalTo(1));
|
||||
|
||||
indexWriter.prepareCommit();
|
||||
reader = indexWriter.getReader();
|
||||
reader = reader.reopen();
|
||||
assertThat(reader.numDocs(), equalTo(1));
|
||||
|
||||
indexWriter.addDocument(doc()
|
||||
.add(field("_id", "2")).build());
|
||||
indexWriter.commit();
|
||||
reader = indexWriter.getReader();
|
||||
reader = reader.reopen();
|
||||
assertThat(reader.numDocs(), equalTo(2));
|
||||
}
|
||||
|
||||
@Test public void testSimpleNumericOps() throws Exception {
|
||||
Directory dir = new RAMDirectory();
|
||||
IndexWriter indexWriter = new IndexWriter(dir, Lucene.STANDARD_ANALYZER, true, IndexWriter.MaxFieldLength.UNLIMITED);
|
||||
IndexWriter indexWriter = new IndexWriter(dir, new IndexWriterConfig(Lucene.VERSION, Lucene.STANDARD_ANALYZER));
|
||||
|
||||
indexWriter.addDocument(doc().add(field("_id", "1")).add(new NumericField("test", Field.Store.YES, true).setIntValue(2)).build());
|
||||
|
||||
IndexSearcher searcher = new IndexSearcher(indexWriter.getReader());
|
||||
IndexReader reader = IndexReader.open(indexWriter, true);
|
||||
IndexSearcher searcher = new IndexSearcher(reader);
|
||||
TopDocs topDocs = searcher.search(new TermQuery(new Term("_id", "1")), 1);
|
||||
Document doc = searcher.doc(topDocs.scoreDocs[0].doc);
|
||||
Fieldable f = doc.getFieldable("test");
|
||||
|
@ -114,13 +116,14 @@ public class SimpleLuceneTests {
|
|||
*/
|
||||
@Test public void testOrdering() throws Exception {
|
||||
Directory dir = new RAMDirectory();
|
||||
IndexWriter indexWriter = new IndexWriter(dir, Lucene.STANDARD_ANALYZER, true, IndexWriter.MaxFieldLength.UNLIMITED);
|
||||
IndexWriter indexWriter = new IndexWriter(dir, new IndexWriterConfig(Lucene.VERSION, Lucene.STANDARD_ANALYZER));
|
||||
|
||||
indexWriter.addDocument(doc()
|
||||
.add(field("_id", "1"))
|
||||
.add(field("#id", "1")).build());
|
||||
|
||||
IndexSearcher searcher = new IndexSearcher(indexWriter.getReader());
|
||||
IndexReader reader = IndexReader.open(indexWriter, true);
|
||||
IndexSearcher searcher = new IndexSearcher(reader);
|
||||
TopDocs topDocs = searcher.search(new TermQuery(new Term("_id", "1")), 1);
|
||||
final ArrayList<String> fieldsOrder = new ArrayList<String>();
|
||||
Document doc = searcher.doc(topDocs.scoreDocs[0].doc, new FieldSelector() {
|
||||
|
@ -139,7 +142,7 @@ public class SimpleLuceneTests {
|
|||
|
||||
@Test public void testCollectorOrdering() throws Exception {
|
||||
Directory dir = new RAMDirectory();
|
||||
IndexWriter indexWriter = new IndexWriter(dir, Lucene.STANDARD_ANALYZER, true, IndexWriter.MaxFieldLength.UNLIMITED);
|
||||
IndexWriter indexWriter = new IndexWriter(dir, new IndexWriterConfig(Lucene.VERSION, Lucene.STANDARD_ANALYZER));
|
||||
for (int i = 0; i < 5000; i++) {
|
||||
indexWriter.addDocument(doc()
|
||||
.add(field("_id", Integer.toString(i))).build());
|
||||
|
@ -147,7 +150,7 @@ public class SimpleLuceneTests {
|
|||
indexWriter.commit();
|
||||
}
|
||||
}
|
||||
IndexReader reader = indexWriter.getReader();
|
||||
IndexReader reader = IndexReader.open(indexWriter, true);
|
||||
IndexSearcher searcher = new IndexSearcher(reader);
|
||||
|
||||
for (int i = 0; i < 5000; i++) {
|
||||
|
@ -181,7 +184,7 @@ public class SimpleLuceneTests {
|
|||
|
||||
@Test public void testBoost() throws Exception {
|
||||
Directory dir = new RAMDirectory();
|
||||
IndexWriter indexWriter = new IndexWriter(dir, Lucene.STANDARD_ANALYZER, true, IndexWriter.MaxFieldLength.UNLIMITED);
|
||||
IndexWriter indexWriter = new IndexWriter(dir, new IndexWriterConfig(Lucene.VERSION, Lucene.STANDARD_ANALYZER));
|
||||
|
||||
for (int i = 0; i < 100; i++) {
|
||||
// TODO (just setting the boost value does not seem to work...)
|
||||
|
@ -195,7 +198,8 @@ public class SimpleLuceneTests {
|
|||
.boost(i).build());
|
||||
}
|
||||
|
||||
IndexSearcher searcher = new IndexSearcher(indexWriter.getReader());
|
||||
IndexReader reader = IndexReader.open(indexWriter, true);
|
||||
IndexSearcher searcher = new IndexSearcher(reader);
|
||||
TermQuery query = new TermQuery(new Term("value", "value"));
|
||||
TopDocs topDocs = searcher.search(query, 100);
|
||||
assertThat(100, equalTo(topDocs.totalHits));
|
||||
|
@ -210,8 +214,8 @@ public class SimpleLuceneTests {
|
|||
|
||||
@Test public void testNRT() throws Exception {
|
||||
Directory dir = new RAMDirectory();
|
||||
IndexWriter indexWriter = new IndexWriter(dir, Lucene.STANDARD_ANALYZER, true, IndexWriter.MaxFieldLength.UNLIMITED);
|
||||
IndexReader reader = indexWriter.getReader();
|
||||
IndexWriter indexWriter = new IndexWriter(dir, new IndexWriterConfig(Lucene.VERSION, Lucene.STANDARD_ANALYZER));
|
||||
IndexReader reader = IndexReader.open(indexWriter, true);
|
||||
|
||||
List<IndexReader> readers = Lists.newArrayList();
|
||||
for (int i = 0; i < 100; i++) {
|
||||
|
@ -247,8 +251,8 @@ public class SimpleLuceneTests {
|
|||
|
||||
@Test public void testNRTSearchOnClosedWriter() throws Exception {
|
||||
Directory dir = new RAMDirectory();
|
||||
IndexWriter indexWriter = new IndexWriter(dir, Lucene.STANDARD_ANALYZER, true, IndexWriter.MaxFieldLength.UNLIMITED);
|
||||
IndexReader reader = indexWriter.getReader();
|
||||
IndexWriter indexWriter = new IndexWriter(dir, new IndexWriterConfig(Lucene.VERSION, Lucene.STANDARD_ANALYZER));
|
||||
IndexReader reader = IndexReader.open(indexWriter, true);
|
||||
|
||||
for (int i = 0; i < 100; i++) {
|
||||
indexWriter.addDocument(doc()
|
||||
|
@ -269,7 +273,7 @@ public class SimpleLuceneTests {
|
|||
*/
|
||||
@Test public void testNumericTermDocsFreqs() throws Exception {
|
||||
Directory dir = new RAMDirectory();
|
||||
IndexWriter indexWriter = new IndexWriter(dir, Lucene.STANDARD_ANALYZER, true, IndexWriter.MaxFieldLength.UNLIMITED);
|
||||
IndexWriter indexWriter = new IndexWriter(dir, new IndexWriterConfig(Lucene.VERSION, Lucene.STANDARD_ANALYZER));
|
||||
|
||||
Document doc = new Document();
|
||||
NumericField field = new NumericField("int1").setIntValue(1);
|
||||
|
@ -294,7 +298,7 @@ public class SimpleLuceneTests {
|
|||
|
||||
indexWriter.addDocument(doc);
|
||||
|
||||
IndexReader reader = indexWriter.getReader();
|
||||
IndexReader reader = IndexReader.open(indexWriter, true);
|
||||
|
||||
TermDocs termDocs = reader.termDocs();
|
||||
|
||||
|
|
|
@ -22,8 +22,13 @@ package org.elasticsearch.deps.lucene;
|
|||
import org.apache.lucene.document.Field;
|
||||
import org.apache.lucene.index.IndexReader;
|
||||
import org.apache.lucene.index.IndexWriter;
|
||||
import org.apache.lucene.index.IndexWriterConfig;
|
||||
import org.apache.lucene.index.Term;
|
||||
import org.apache.lucene.search.*;
|
||||
import org.apache.lucene.search.IndexSearcher;
|
||||
import org.apache.lucene.search.PrefixQuery;
|
||||
import org.apache.lucene.search.Query;
|
||||
import org.apache.lucene.search.TermQuery;
|
||||
import org.apache.lucene.search.TopDocs;
|
||||
import org.apache.lucene.search.vectorhighlight.CustomFieldQuery;
|
||||
import org.apache.lucene.search.vectorhighlight.FastVectorHighlighter;
|
||||
import org.apache.lucene.store.Directory;
|
||||
|
@ -43,11 +48,11 @@ public class VectorHighlighterTests {
|
|||
|
||||
@Test public void testVectorHighlighter() throws Exception {
|
||||
Directory dir = new RAMDirectory();
|
||||
IndexWriter indexWriter = new IndexWriter(dir, Lucene.STANDARD_ANALYZER, true, IndexWriter.MaxFieldLength.UNLIMITED);
|
||||
IndexWriter indexWriter = new IndexWriter(dir, new IndexWriterConfig(Lucene.VERSION, Lucene.STANDARD_ANALYZER));
|
||||
|
||||
indexWriter.addDocument(doc().add(field("_id", "1")).add(field("content", "the big bad dog", Field.Store.YES, Field.Index.ANALYZED, Field.TermVector.WITH_POSITIONS_OFFSETS)).build());
|
||||
|
||||
IndexReader reader = indexWriter.getReader();
|
||||
IndexReader reader = IndexReader.open(indexWriter, true);
|
||||
IndexSearcher searcher = new IndexSearcher(reader);
|
||||
TopDocs topDocs = searcher.search(new TermQuery(new Term("_id", "1")), 1);
|
||||
|
||||
|
@ -62,11 +67,11 @@ public class VectorHighlighterTests {
|
|||
|
||||
@Test public void testVectorHighlighterPrefixQuery() throws Exception {
|
||||
Directory dir = new RAMDirectory();
|
||||
IndexWriter indexWriter = new IndexWriter(dir, Lucene.STANDARD_ANALYZER, true, IndexWriter.MaxFieldLength.UNLIMITED);
|
||||
IndexWriter indexWriter = new IndexWriter(dir, new IndexWriterConfig(Lucene.VERSION, Lucene.STANDARD_ANALYZER));
|
||||
|
||||
indexWriter.addDocument(doc().add(field("_id", "1")).add(field("content", "the big bad dog", Field.Store.YES, Field.Index.ANALYZED, Field.TermVector.WITH_POSITIONS_OFFSETS)).build());
|
||||
|
||||
IndexReader reader = indexWriter.getReader();
|
||||
IndexReader reader = IndexReader.open(indexWriter, true);
|
||||
IndexSearcher searcher = new IndexSearcher(reader);
|
||||
TopDocs topDocs = searcher.search(new TermQuery(new Term("_id", "1")), 1);
|
||||
|
||||
|
@ -101,11 +106,11 @@ public class VectorHighlighterTests {
|
|||
|
||||
@Test public void testVectorHighlighterNoStore() throws Exception {
|
||||
Directory dir = new RAMDirectory();
|
||||
IndexWriter indexWriter = new IndexWriter(dir, Lucene.STANDARD_ANALYZER, true, IndexWriter.MaxFieldLength.UNLIMITED);
|
||||
IndexWriter indexWriter = new IndexWriter(dir, new IndexWriterConfig(Lucene.VERSION, Lucene.STANDARD_ANALYZER));
|
||||
|
||||
indexWriter.addDocument(doc().add(field("_id", "1")).add(field("content", "the big bad dog", Field.Store.NO, Field.Index.ANALYZED, Field.TermVector.WITH_POSITIONS_OFFSETS)).build());
|
||||
|
||||
IndexReader reader = indexWriter.getReader();
|
||||
IndexReader reader = IndexReader.open(indexWriter, true);
|
||||
IndexSearcher searcher = new IndexSearcher(reader);
|
||||
TopDocs topDocs = searcher.search(new TermQuery(new Term("_id", "1")), 1);
|
||||
|
||||
|
@ -119,11 +124,11 @@ public class VectorHighlighterTests {
|
|||
|
||||
@Test public void testVectorHighlighterNoTermVector() throws Exception {
|
||||
Directory dir = new RAMDirectory();
|
||||
IndexWriter indexWriter = new IndexWriter(dir, Lucene.STANDARD_ANALYZER, true, IndexWriter.MaxFieldLength.UNLIMITED);
|
||||
IndexWriter indexWriter = new IndexWriter(dir, new IndexWriterConfig(Lucene.VERSION, Lucene.STANDARD_ANALYZER));
|
||||
|
||||
indexWriter.addDocument(doc().add(field("_id", "1")).add(field("content", "the big bad dog", Field.Store.YES, Field.Index.ANALYZED, Field.TermVector.NO)).build());
|
||||
|
||||
IndexReader reader = indexWriter.getReader();
|
||||
IndexReader reader = IndexReader.open(indexWriter, true);
|
||||
IndexSearcher searcher = new IndexSearcher(reader);
|
||||
TopDocs topDocs = searcher.search(new TermQuery(new Term("_id", "1")), 1);
|
||||
|
||||
|
|
|
@ -21,8 +21,14 @@ package org.elasticsearch.index.cache.filter;
|
|||
|
||||
import org.apache.lucene.index.IndexReader;
|
||||
import org.apache.lucene.index.IndexWriter;
|
||||
import org.apache.lucene.index.IndexWriterConfig;
|
||||
import org.apache.lucene.index.Term;
|
||||
import org.apache.lucene.search.*;
|
||||
import org.apache.lucene.search.ConstantScoreQuery;
|
||||
import org.apache.lucene.search.DeletionAwareConstantScoreQuery;
|
||||
import org.apache.lucene.search.Filter;
|
||||
import org.apache.lucene.search.FilteredQuery;
|
||||
import org.apache.lucene.search.IndexSearcher;
|
||||
import org.apache.lucene.search.MatchAllDocsQuery;
|
||||
import org.apache.lucene.store.Directory;
|
||||
import org.apache.lucene.store.RAMDirectory;
|
||||
import org.elasticsearch.common.lucene.Lucene;
|
||||
|
@ -61,8 +67,8 @@ public class FilterCacheTests {
|
|||
|
||||
private void verifyCache(FilterCache filterCache) throws Exception {
|
||||
Directory dir = new RAMDirectory();
|
||||
IndexWriter indexWriter = new IndexWriter(dir, Lucene.STANDARD_ANALYZER, true, IndexWriter.MaxFieldLength.UNLIMITED);
|
||||
IndexReader reader = indexWriter.getReader();
|
||||
IndexWriter indexWriter = new IndexWriter(dir, new IndexWriterConfig(Lucene.VERSION, Lucene.STANDARD_ANALYZER));
|
||||
IndexReader reader = IndexReader.open(indexWriter, true);
|
||||
|
||||
for (int i = 0; i < 100; i++) {
|
||||
indexWriter.addDocument(doc()
|
||||
|
|
|
@ -22,6 +22,7 @@ package org.elasticsearch.index.field.data.doubles;
|
|||
import org.apache.lucene.document.NumericField;
|
||||
import org.apache.lucene.index.IndexReader;
|
||||
import org.apache.lucene.index.IndexWriter;
|
||||
import org.apache.lucene.index.IndexWriterConfig;
|
||||
import org.apache.lucene.store.Directory;
|
||||
import org.apache.lucene.store.RAMDirectory;
|
||||
import org.elasticsearch.common.lucene.Lucene;
|
||||
|
@ -40,7 +41,7 @@ public class DoubleFieldDataTests {
|
|||
|
||||
@Test public void intFieldDataTests() throws Exception {
|
||||
Directory dir = new RAMDirectory();
|
||||
IndexWriter indexWriter = new IndexWriter(dir, Lucene.STANDARD_ANALYZER, true, IndexWriter.MaxFieldLength.UNLIMITED);
|
||||
IndexWriter indexWriter = new IndexWriter(dir, new IndexWriterConfig(Lucene.VERSION, Lucene.STANDARD_ANALYZER));
|
||||
|
||||
indexWriter.addDocument(doc()
|
||||
.add(new NumericField("svalue").setDoubleValue(4))
|
||||
|
@ -65,7 +66,7 @@ public class DoubleFieldDataTests {
|
|||
.add(new NumericField("svalue").setDoubleValue(4))
|
||||
.build());
|
||||
|
||||
IndexReader reader = indexWriter.getReader();
|
||||
IndexReader reader = IndexReader.open(indexWriter, true);
|
||||
|
||||
DoubleFieldData sFieldData = DoubleFieldData.load(reader, "svalue");
|
||||
DoubleFieldData mFieldData = DoubleFieldData.load(reader, "mvalue");
|
||||
|
|
|
@ -22,6 +22,7 @@ package org.elasticsearch.index.field.data.floats;
|
|||
import org.apache.lucene.document.NumericField;
|
||||
import org.apache.lucene.index.IndexReader;
|
||||
import org.apache.lucene.index.IndexWriter;
|
||||
import org.apache.lucene.index.IndexWriterConfig;
|
||||
import org.apache.lucene.store.Directory;
|
||||
import org.apache.lucene.store.RAMDirectory;
|
||||
import org.elasticsearch.common.lucene.Lucene;
|
||||
|
@ -40,7 +41,7 @@ public class FloatFieldDataTests {
|
|||
|
||||
@Test public void intFieldDataTests() throws Exception {
|
||||
Directory dir = new RAMDirectory();
|
||||
IndexWriter indexWriter = new IndexWriter(dir, Lucene.STANDARD_ANALYZER, true, IndexWriter.MaxFieldLength.UNLIMITED);
|
||||
IndexWriter indexWriter = new IndexWriter(dir, new IndexWriterConfig(Lucene.VERSION, Lucene.STANDARD_ANALYZER));
|
||||
|
||||
indexWriter.addDocument(doc()
|
||||
.add(new NumericField("svalue").setFloatValue(4))
|
||||
|
@ -65,7 +66,7 @@ public class FloatFieldDataTests {
|
|||
.add(new NumericField("svalue").setFloatValue(4))
|
||||
.build());
|
||||
|
||||
IndexReader reader = indexWriter.getReader();
|
||||
IndexReader reader = IndexReader.open(indexWriter, true);
|
||||
|
||||
FloatFieldData sFieldData = FloatFieldData.load(reader, "svalue");
|
||||
FloatFieldData mFieldData = FloatFieldData.load(reader, "mvalue");
|
||||
|
|
|
@ -66,7 +66,7 @@ public class IntFieldDataTests {
|
|||
.add(new NumericField("svalue").setIntValue(4))
|
||||
.build());
|
||||
|
||||
IndexReader reader = indexWriter.getReader();
|
||||
IndexReader reader = IndexReader.open(indexWriter, true);
|
||||
|
||||
IntFieldData sFieldData = IntFieldData.load(reader, "svalue");
|
||||
IntFieldData mFieldData = IntFieldData.load(reader, "mvalue");
|
||||
|
|
|
@ -22,6 +22,7 @@ package org.elasticsearch.index.field.data.longs;
|
|||
import org.apache.lucene.document.NumericField;
|
||||
import org.apache.lucene.index.IndexReader;
|
||||
import org.apache.lucene.index.IndexWriter;
|
||||
import org.apache.lucene.index.IndexWriterConfig;
|
||||
import org.apache.lucene.store.Directory;
|
||||
import org.apache.lucene.store.RAMDirectory;
|
||||
import org.elasticsearch.common.lucene.Lucene;
|
||||
|
@ -40,7 +41,7 @@ public class LongFieldDataTests {
|
|||
|
||||
@Test public void intFieldDataTests() throws Exception {
|
||||
Directory dir = new RAMDirectory();
|
||||
IndexWriter indexWriter = new IndexWriter(dir, Lucene.STANDARD_ANALYZER, true, IndexWriter.MaxFieldLength.UNLIMITED);
|
||||
IndexWriter indexWriter = new IndexWriter(dir, new IndexWriterConfig(Lucene.VERSION, Lucene.STANDARD_ANALYZER));
|
||||
|
||||
indexWriter.addDocument(doc()
|
||||
.add(new NumericField("svalue").setLongValue(4))
|
||||
|
@ -65,7 +66,7 @@ public class LongFieldDataTests {
|
|||
.add(new NumericField("svalue").setLongValue(4))
|
||||
.build());
|
||||
|
||||
IndexReader reader = indexWriter.getReader();
|
||||
IndexReader reader = IndexReader.open(indexWriter, true);
|
||||
|
||||
LongFieldData sFieldData = LongFieldData.load(reader, "svalue");
|
||||
LongFieldData mFieldData = LongFieldData.load(reader, "mvalue");
|
||||
|
|
|
@ -22,6 +22,7 @@ package org.elasticsearch.index.field.data.shorts;
|
|||
import org.apache.lucene.document.NumericField;
|
||||
import org.apache.lucene.index.IndexReader;
|
||||
import org.apache.lucene.index.IndexWriter;
|
||||
import org.apache.lucene.index.IndexWriterConfig;
|
||||
import org.apache.lucene.store.Directory;
|
||||
import org.apache.lucene.store.RAMDirectory;
|
||||
import org.elasticsearch.common.lucene.Lucene;
|
||||
|
@ -40,7 +41,7 @@ public class ShortFieldDataTests {
|
|||
|
||||
@Test public void intFieldDataTests() throws Exception {
|
||||
Directory dir = new RAMDirectory();
|
||||
IndexWriter indexWriter = new IndexWriter(dir, Lucene.STANDARD_ANALYZER, true, IndexWriter.MaxFieldLength.UNLIMITED);
|
||||
IndexWriter indexWriter = new IndexWriter(dir, new IndexWriterConfig(Lucene.VERSION, Lucene.STANDARD_ANALYZER));
|
||||
|
||||
indexWriter.addDocument(doc()
|
||||
.add(new NumericField("svalue").setIntValue(4))
|
||||
|
@ -65,7 +66,7 @@ public class ShortFieldDataTests {
|
|||
.add(new NumericField("svalue").setIntValue(4))
|
||||
.build());
|
||||
|
||||
IndexReader reader = indexWriter.getReader();
|
||||
IndexReader reader = IndexReader.open(indexWriter, true);
|
||||
|
||||
ShortFieldData sFieldData = ShortFieldData.load(reader, "svalue");
|
||||
ShortFieldData mFieldData = ShortFieldData.load(reader, "mvalue");
|
||||
|
|
|
@ -21,6 +21,7 @@ package org.elasticsearch.index.field.data.strings;
|
|||
|
||||
import org.apache.lucene.index.IndexReader;
|
||||
import org.apache.lucene.index.IndexWriter;
|
||||
import org.apache.lucene.index.IndexWriterConfig;
|
||||
import org.apache.lucene.store.Directory;
|
||||
import org.apache.lucene.store.RAMDirectory;
|
||||
import org.elasticsearch.common.lucene.Lucene;
|
||||
|
@ -40,7 +41,7 @@ public class StringFieldDataTests {
|
|||
|
||||
@Test public void stringFieldDataTests() throws Exception {
|
||||
Directory dir = new RAMDirectory();
|
||||
IndexWriter indexWriter = new IndexWriter(dir, Lucene.STANDARD_ANALYZER, true, IndexWriter.MaxFieldLength.UNLIMITED);
|
||||
IndexWriter indexWriter = new IndexWriter(dir, new IndexWriterConfig(Lucene.VERSION, Lucene.STANDARD_ANALYZER));
|
||||
|
||||
indexWriter.addDocument(doc()
|
||||
.add(field("svalue", "zzz"))
|
||||
|
@ -59,7 +60,7 @@ public class StringFieldDataTests {
|
|||
indexWriter.addDocument(doc()
|
||||
.add(field("svalue", "aaa")).build());
|
||||
|
||||
IndexReader reader = indexWriter.getReader();
|
||||
IndexReader reader = IndexReader.open(indexWriter, true);
|
||||
|
||||
StringFieldData sFieldData = StringFieldData.load(reader, "svalue");
|
||||
StringFieldData mFieldData = StringFieldData.load(reader, "mvalue");
|
||||
|
|
|
@ -41,7 +41,7 @@ public class SimpleAllMapperTests {
|
|||
String mapping = copyToStringFromClasspath("/org/elasticsearch/index/mapper/all/mapping.json");
|
||||
DocumentMapper docMapper = MapperTests.newParser().parse(mapping);
|
||||
byte[] json = copyToBytesFromClasspath("/org/elasticsearch/index/mapper/all/test1.json");
|
||||
Document doc = docMapper.parse(json).masterDoc();
|
||||
Document doc = docMapper.parse(json).rootDoc();
|
||||
AllField field = (AllField) doc.getFieldable("_all");
|
||||
AllEntries allEntries = ((AllTokenStream) field.tokenStreamValue()).allEntries();
|
||||
assertThat(allEntries.fields().size(), equalTo(3));
|
||||
|
@ -58,7 +58,7 @@ public class SimpleAllMapperTests {
|
|||
// reparse it
|
||||
DocumentMapper builtDocMapper = MapperTests.newParser().parse(builtMapping);
|
||||
byte[] json = copyToBytesFromClasspath("/org/elasticsearch/index/mapper/all/test1.json");
|
||||
Document doc = builtDocMapper.parse(json).masterDoc();
|
||||
Document doc = builtDocMapper.parse(json).rootDoc();
|
||||
|
||||
AllField field = (AllField) doc.getFieldable("_all");
|
||||
AllEntries allEntries = ((AllTokenStream) field.tokenStreamValue()).allEntries();
|
||||
|
@ -72,7 +72,7 @@ public class SimpleAllMapperTests {
|
|||
String mapping = copyToStringFromClasspath("/org/elasticsearch/index/mapper/all/store-mapping.json");
|
||||
DocumentMapper docMapper = MapperTests.newParser().parse(mapping);
|
||||
byte[] json = copyToBytesFromClasspath("/org/elasticsearch/index/mapper/all/test1.json");
|
||||
Document doc = docMapper.parse(json).masterDoc();
|
||||
Document doc = docMapper.parse(json).rootDoc();
|
||||
AllField field = (AllField) doc.getFieldable("_all");
|
||||
AllEntries allEntries = ((AllTokenStream) field.tokenStreamValue()).allEntries();
|
||||
assertThat(allEntries.fields().size(), equalTo(2));
|
||||
|
@ -91,7 +91,7 @@ public class SimpleAllMapperTests {
|
|||
// reparse it
|
||||
DocumentMapper builtDocMapper = MapperTests.newParser().parse(builtMapping);
|
||||
byte[] json = copyToBytesFromClasspath("/org/elasticsearch/index/mapper/all/test1.json");
|
||||
Document doc = builtDocMapper.parse(json).masterDoc();
|
||||
Document doc = builtDocMapper.parse(json).rootDoc();
|
||||
|
||||
AllField field = (AllField) doc.getFieldable("_all");
|
||||
AllEntries allEntries = ((AllTokenStream) field.tokenStreamValue()).allEntries();
|
||||
|
|
|
@ -56,13 +56,13 @@ public class CustomBoostMappingTests {
|
|||
.startObject("date_field").field("value", "20100101").field("boost", 9.0f).endObject()
|
||||
.endObject().copiedBytes());
|
||||
|
||||
assertThat(doc.masterDoc().getFieldable("s_field").getBoost(), equalTo(2.0f));
|
||||
assertThat(doc.masterDoc().getFieldable("l_field").getBoost(), equalTo(3.0f));
|
||||
assertThat(doc.masterDoc().getFieldable("i_field").getBoost(), equalTo(4.0f));
|
||||
assertThat(doc.masterDoc().getFieldable("sh_field").getBoost(), equalTo(5.0f));
|
||||
assertThat(doc.masterDoc().getFieldable("b_field").getBoost(), equalTo(6.0f));
|
||||
assertThat(doc.masterDoc().getFieldable("d_field").getBoost(), equalTo(7.0f));
|
||||
assertThat(doc.masterDoc().getFieldable("f_field").getBoost(), equalTo(8.0f));
|
||||
assertThat(doc.masterDoc().getFieldable("date_field").getBoost(), equalTo(9.0f));
|
||||
assertThat(doc.rootDoc().getFieldable("s_field").getBoost(), equalTo(2.0f));
|
||||
assertThat(doc.rootDoc().getFieldable("l_field").getBoost(), equalTo(3.0f));
|
||||
assertThat(doc.rootDoc().getFieldable("i_field").getBoost(), equalTo(4.0f));
|
||||
assertThat(doc.rootDoc().getFieldable("sh_field").getBoost(), equalTo(5.0f));
|
||||
assertThat(doc.rootDoc().getFieldable("b_field").getBoost(), equalTo(6.0f));
|
||||
assertThat(doc.rootDoc().getFieldable("d_field").getBoost(), equalTo(7.0f));
|
||||
assertThat(doc.rootDoc().getFieldable("f_field").getBoost(), equalTo(8.0f));
|
||||
assertThat(doc.rootDoc().getFieldable("date_field").getBoost(), equalTo(9.0f));
|
||||
}
|
||||
}
|
|
@ -46,9 +46,9 @@ public class CompoundTypesTests {
|
|||
.field("field2", "value2")
|
||||
.copiedBytes());
|
||||
|
||||
assertThat(doc.masterDoc().get("field1"), equalTo("value1"));
|
||||
assertThat((double) doc.masterDoc().getFieldable("field1").getBoost(), closeTo(1.0d, 0.000001d));
|
||||
assertThat(doc.masterDoc().get("field2"), equalTo("value2"));
|
||||
assertThat(doc.rootDoc().get("field1"), equalTo("value1"));
|
||||
assertThat((double) doc.rootDoc().getFieldable("field1").getBoost(), closeTo(1.0d, 0.000001d));
|
||||
assertThat(doc.rootDoc().get("field2"), equalTo("value2"));
|
||||
|
||||
doc = defaultMapper.parse("type", "1", XContentFactory.jsonBuilder()
|
||||
.startObject()
|
||||
|
@ -56,9 +56,9 @@ public class CompoundTypesTests {
|
|||
.field("field2", "value2")
|
||||
.copiedBytes());
|
||||
|
||||
assertThat(doc.masterDoc().get("field1"), equalTo("value1"));
|
||||
assertThat((double) doc.masterDoc().getFieldable("field1").getBoost(), closeTo(2.0d, 0.000001d));
|
||||
assertThat(doc.masterDoc().get("field2"), equalTo("value2"));
|
||||
assertThat(doc.rootDoc().get("field1"), equalTo("value1"));
|
||||
assertThat((double) doc.rootDoc().getFieldable("field1").getBoost(), closeTo(2.0d, 0.000001d));
|
||||
assertThat(doc.rootDoc().get("field2"), equalTo("value2"));
|
||||
|
||||
doc = defaultMapper.parse("type", "1", XContentFactory.jsonBuilder()
|
||||
.startObject()
|
||||
|
@ -66,8 +66,8 @@ public class CompoundTypesTests {
|
|||
.field("field2", "value2")
|
||||
.copiedBytes());
|
||||
|
||||
assertThat(doc.masterDoc().get("field1"), equalTo("value1"));
|
||||
assertThat((double) doc.masterDoc().getFieldable("field1").getBoost(), closeTo(1.0d, 0.000001d));
|
||||
assertThat(doc.masterDoc().get("field2"), equalTo("value2"));
|
||||
assertThat(doc.rootDoc().get("field1"), equalTo("value1"));
|
||||
assertThat((double) doc.rootDoc().getFieldable("field1").getBoost(), closeTo(1.0d, 0.000001d));
|
||||
assertThat(doc.rootDoc().get("field2"), equalTo("value2"));
|
||||
}
|
||||
}
|
|
@ -45,7 +45,7 @@ public class SimpleDateMappingTests {
|
|||
.endObject()
|
||||
.copiedBytes());
|
||||
|
||||
assertThat(doc.masterDoc().getFieldable("date_field").tokenStreamValue(), notNullValue());
|
||||
assertThat(doc.rootDoc().getFieldable("date_field").tokenStreamValue(), notNullValue());
|
||||
}
|
||||
|
||||
@Test public void testDateDetection() throws Exception {
|
||||
|
@ -63,7 +63,7 @@ public class SimpleDateMappingTests {
|
|||
.endObject()
|
||||
.copiedBytes());
|
||||
|
||||
assertThat(doc.masterDoc().get("date_field"), nullValue());
|
||||
assertThat(doc.masterDoc().get("date_field_x"), equalTo("2010-01-01"));
|
||||
assertThat(doc.rootDoc().get("date_field"), nullValue());
|
||||
assertThat(doc.rootDoc().get("date_field_x"), equalTo("2010-01-01"));
|
||||
}
|
||||
}
|
|
@ -50,8 +50,8 @@ public class DynamicMappingTests {
|
|||
.field("field2", "value2")
|
||||
.copiedBytes());
|
||||
|
||||
assertThat(doc.masterDoc().get("field1"), equalTo("value1"));
|
||||
assertThat(doc.masterDoc().get("field2"), equalTo("value2"));
|
||||
assertThat(doc.rootDoc().get("field1"), equalTo("value1"));
|
||||
assertThat(doc.rootDoc().get("field2"), equalTo("value2"));
|
||||
}
|
||||
|
||||
@Test public void testDynamicFalse() throws IOException {
|
||||
|
@ -70,8 +70,8 @@ public class DynamicMappingTests {
|
|||
.field("field2", "value2")
|
||||
.copiedBytes());
|
||||
|
||||
assertThat(doc.masterDoc().get("field1"), equalTo("value1"));
|
||||
assertThat(doc.masterDoc().get("field2"), nullValue());
|
||||
assertThat(doc.rootDoc().get("field1"), equalTo("value1"));
|
||||
assertThat(doc.rootDoc().get("field2"), nullValue());
|
||||
}
|
||||
|
||||
|
||||
|
@ -116,8 +116,8 @@ public class DynamicMappingTests {
|
|||
.endObject()
|
||||
.copiedBytes());
|
||||
|
||||
assertThat(doc.masterDoc().get("obj1.field1"), equalTo("value1"));
|
||||
assertThat(doc.masterDoc().get("obj1.field2"), nullValue());
|
||||
assertThat(doc.rootDoc().get("obj1.field1"), equalTo("value1"));
|
||||
assertThat(doc.rootDoc().get("obj1.field2"), nullValue());
|
||||
}
|
||||
|
||||
@Test public void testDynamicStrictWithInnerObjectButDynamicSetOnRoot() throws IOException {
|
||||
|
|
|
@ -39,7 +39,7 @@ public class GenericStoreDynamicTemplateTests {
|
|||
String mapping = copyToStringFromClasspath("/org/elasticsearch/index/mapper/dynamictemplate/genericstore/test-mapping.json");
|
||||
DocumentMapper docMapper = MapperTests.newParser().parse(mapping);
|
||||
byte[] json = copyToBytesFromClasspath("/org/elasticsearch/index/mapper/dynamictemplate/genericstore/test-data.json");
|
||||
Document doc = docMapper.parse(json).masterDoc();
|
||||
Document doc = docMapper.parse(json).rootDoc();
|
||||
|
||||
Fieldable f = doc.getFieldable("name");
|
||||
assertThat(f.name(), equalTo("name"));
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
package org.elasticsearch.index.mapper.dynamictemplate.pathmatch;
|
||||
|
||||
import org.apache.lucene.document.Document;
|
||||
import org.apache.lucene.document.Field;
|
||||
import org.apache.lucene.document.Fieldable;
|
||||
import org.elasticsearch.index.mapper.DocumentMapper;
|
||||
import org.elasticsearch.index.mapper.FieldMappers;
|
||||
import org.elasticsearch.index.mapper.MapperTests;
|
||||
|
@ -39,9 +39,9 @@ public class PathMatchDynamicTempalteTests {
|
|||
String mapping = copyToStringFromClasspath("/org/elasticsearch/index/mapper/dynamictemplate/pathmatch/test-mapping.json");
|
||||
DocumentMapper docMapper = MapperTests.newParser().parse(mapping);
|
||||
byte[] json = copyToBytesFromClasspath("/org/elasticsearch/index/mapper/dynamictemplate/pathmatch/test-data.json");
|
||||
Document doc = docMapper.parse(json).masterDoc();
|
||||
Document doc = docMapper.parse(json).rootDoc();
|
||||
|
||||
Field f = doc.getField("name");
|
||||
Fieldable f = doc.getFieldable("name");
|
||||
assertThat(f.name(), equalTo("name"));
|
||||
assertThat(f.stringValue(), equalTo("top_level"));
|
||||
assertThat(f.isStored(), equalTo(false));
|
||||
|
@ -50,7 +50,7 @@ public class PathMatchDynamicTempalteTests {
|
|||
assertThat(fieldMappers.mappers().size(), equalTo(1));
|
||||
assertThat(fieldMappers.mapper().stored(), equalTo(false));
|
||||
|
||||
f = doc.getField("obj1.name");
|
||||
f = doc.getFieldable("obj1.name");
|
||||
assertThat(f.name(), equalTo("obj1.name"));
|
||||
assertThat(f.isStored(), equalTo(true));
|
||||
|
||||
|
@ -58,7 +58,7 @@ public class PathMatchDynamicTempalteTests {
|
|||
assertThat(fieldMappers.mappers().size(), equalTo(1));
|
||||
assertThat(fieldMappers.mapper().stored(), equalTo(true));
|
||||
|
||||
f = doc.getField("obj1.obj2.name");
|
||||
f = doc.getFieldable("obj1.obj2.name");
|
||||
assertThat(f.name(), equalTo("obj1.obj2.name"));
|
||||
assertThat(f.isStored(), equalTo(false));
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
package org.elasticsearch.index.mapper.dynamictemplate.simple;
|
||||
|
||||
import org.apache.lucene.document.Document;
|
||||
import org.apache.lucene.document.Field;
|
||||
import org.apache.lucene.document.Fieldable;
|
||||
import org.elasticsearch.index.mapper.DocumentMapper;
|
||||
import org.elasticsearch.index.mapper.FieldMappers;
|
||||
import org.elasticsearch.index.mapper.MapperTests;
|
||||
|
@ -39,9 +39,9 @@ public class SimpleDynamicTemplatesTests {
|
|||
String mapping = copyToStringFromClasspath("/org/elasticsearch/index/mapper/dynamictemplate/simple/test-mapping.json");
|
||||
DocumentMapper docMapper = MapperTests.newParser().parse(mapping);
|
||||
byte[] json = copyToBytesFromClasspath("/org/elasticsearch/index/mapper/dynamictemplate/simple/test-data.json");
|
||||
Document doc = docMapper.parse(json).masterDoc();
|
||||
Document doc = docMapper.parse(json).rootDoc();
|
||||
|
||||
Field f = doc.getField("name");
|
||||
Fieldable f = doc.getFieldable("name");
|
||||
assertThat(f.name(), equalTo("name"));
|
||||
assertThat(f.stringValue(), equalTo("some name"));
|
||||
assertThat(f.isIndexed(), equalTo(true));
|
||||
|
@ -50,7 +50,7 @@ public class SimpleDynamicTemplatesTests {
|
|||
FieldMappers fieldMappers = docMapper.mappers().fullName("name");
|
||||
assertThat(fieldMappers.mappers().size(), equalTo(1));
|
||||
|
||||
f = doc.getField("multi1");
|
||||
f = doc.getFieldable("multi1");
|
||||
assertThat(f.name(), equalTo("multi1"));
|
||||
assertThat(f.stringValue(), equalTo("multi 1"));
|
||||
assertThat(f.isIndexed(), equalTo(true));
|
||||
|
@ -59,7 +59,7 @@ public class SimpleDynamicTemplatesTests {
|
|||
fieldMappers = docMapper.mappers().fullName("multi1");
|
||||
assertThat(fieldMappers.mappers().size(), equalTo(1));
|
||||
|
||||
f = doc.getField("multi1.org");
|
||||
f = doc.getFieldable("multi1.org");
|
||||
assertThat(f.name(), equalTo("multi1.org"));
|
||||
assertThat(f.stringValue(), equalTo("multi 1"));
|
||||
assertThat(f.isIndexed(), equalTo(true));
|
||||
|
@ -68,7 +68,7 @@ public class SimpleDynamicTemplatesTests {
|
|||
fieldMappers = docMapper.mappers().fullName("multi1.org");
|
||||
assertThat(fieldMappers.mappers().size(), equalTo(1));
|
||||
|
||||
f = doc.getField("multi2");
|
||||
f = doc.getFieldable("multi2");
|
||||
assertThat(f.name(), equalTo("multi2"));
|
||||
assertThat(f.stringValue(), equalTo("multi 2"));
|
||||
assertThat(f.isIndexed(), equalTo(true));
|
||||
|
@ -77,7 +77,7 @@ public class SimpleDynamicTemplatesTests {
|
|||
fieldMappers = docMapper.mappers().fullName("multi2");
|
||||
assertThat(fieldMappers.mappers().size(), equalTo(1));
|
||||
|
||||
f = doc.getField("multi2.org");
|
||||
f = doc.getFieldable("multi2.org");
|
||||
assertThat(f.name(), equalTo("multi2.org"));
|
||||
assertThat(f.stringValue(), equalTo("multi 2"));
|
||||
assertThat(f.isIndexed(), equalTo(true));
|
||||
|
@ -94,9 +94,9 @@ public class SimpleDynamicTemplatesTests {
|
|||
docMapper = MapperTests.newParser().parse(docMapper.mappingSource().string());
|
||||
|
||||
byte[] json = copyToBytesFromClasspath("/org/elasticsearch/index/mapper/dynamictemplate/simple/test-data.json");
|
||||
Document doc = docMapper.parse(json).masterDoc();
|
||||
Document doc = docMapper.parse(json).rootDoc();
|
||||
|
||||
Field f = doc.getField("name");
|
||||
Fieldable f = doc.getFieldable("name");
|
||||
assertThat(f.name(), equalTo("name"));
|
||||
assertThat(f.stringValue(), equalTo("some name"));
|
||||
assertThat(f.isIndexed(), equalTo(true));
|
||||
|
@ -105,7 +105,7 @@ public class SimpleDynamicTemplatesTests {
|
|||
FieldMappers fieldMappers = docMapper.mappers().fullName("name");
|
||||
assertThat(fieldMappers.mappers().size(), equalTo(1));
|
||||
|
||||
f = doc.getField("multi1");
|
||||
f = doc.getFieldable("multi1");
|
||||
assertThat(f.name(), equalTo("multi1"));
|
||||
assertThat(f.stringValue(), equalTo("multi 1"));
|
||||
assertThat(f.isIndexed(), equalTo(true));
|
||||
|
@ -114,7 +114,7 @@ public class SimpleDynamicTemplatesTests {
|
|||
fieldMappers = docMapper.mappers().fullName("multi1");
|
||||
assertThat(fieldMappers.mappers().size(), equalTo(1));
|
||||
|
||||
f = doc.getField("multi1.org");
|
||||
f = doc.getFieldable("multi1.org");
|
||||
assertThat(f.name(), equalTo("multi1.org"));
|
||||
assertThat(f.stringValue(), equalTo("multi 1"));
|
||||
assertThat(f.isIndexed(), equalTo(true));
|
||||
|
@ -123,7 +123,7 @@ public class SimpleDynamicTemplatesTests {
|
|||
fieldMappers = docMapper.mappers().fullName("multi1.org");
|
||||
assertThat(fieldMappers.mappers().size(), equalTo(1));
|
||||
|
||||
f = doc.getField("multi2");
|
||||
f = doc.getFieldable("multi2");
|
||||
assertThat(f.name(), equalTo("multi2"));
|
||||
assertThat(f.stringValue(), equalTo("multi 2"));
|
||||
assertThat(f.isIndexed(), equalTo(true));
|
||||
|
@ -132,7 +132,7 @@ public class SimpleDynamicTemplatesTests {
|
|||
fieldMappers = docMapper.mappers().fullName("multi2");
|
||||
assertThat(fieldMappers.mappers().size(), equalTo(1));
|
||||
|
||||
f = doc.getField("multi2.org");
|
||||
f = doc.getFieldable("multi2.org");
|
||||
assertThat(f.name(), equalTo("multi2.org"));
|
||||
assertThat(f.stringValue(), equalTo("multi 2"));
|
||||
assertThat(f.isIndexed(), equalTo(true));
|
||||
|
|
|
@ -47,9 +47,9 @@ public class GeohashMappingGeoPointTests {
|
|||
.endObject()
|
||||
.copiedBytes());
|
||||
|
||||
MatcherAssert.assertThat(doc.masterDoc().getFieldable("point.lat"), nullValue());
|
||||
MatcherAssert.assertThat(doc.masterDoc().getFieldable("point.lon"), nullValue());
|
||||
MatcherAssert.assertThat(doc.masterDoc().get("point"), equalTo("1.2,1.3"));
|
||||
MatcherAssert.assertThat(doc.rootDoc().getFieldable("point.lat"), nullValue());
|
||||
MatcherAssert.assertThat(doc.rootDoc().getFieldable("point.lon"), nullValue());
|
||||
MatcherAssert.assertThat(doc.rootDoc().get("point"), equalTo("1.2,1.3"));
|
||||
}
|
||||
|
||||
@Test public void testLatLonInOneValue() throws Exception {
|
||||
|
@ -65,9 +65,9 @@ public class GeohashMappingGeoPointTests {
|
|||
.endObject()
|
||||
.copiedBytes());
|
||||
|
||||
MatcherAssert.assertThat(doc.masterDoc().getFieldable("point.lat"), nullValue());
|
||||
MatcherAssert.assertThat(doc.masterDoc().getFieldable("point.lon"), nullValue());
|
||||
MatcherAssert.assertThat(doc.masterDoc().get("point"), equalTo("1.2,1.3"));
|
||||
MatcherAssert.assertThat(doc.rootDoc().getFieldable("point.lat"), nullValue());
|
||||
MatcherAssert.assertThat(doc.rootDoc().getFieldable("point.lon"), nullValue());
|
||||
MatcherAssert.assertThat(doc.rootDoc().get("point"), equalTo("1.2,1.3"));
|
||||
}
|
||||
|
||||
@Test public void testGeoHashValue() throws Exception {
|
||||
|
@ -83,9 +83,9 @@ public class GeohashMappingGeoPointTests {
|
|||
.endObject()
|
||||
.copiedBytes());
|
||||
|
||||
MatcherAssert.assertThat(doc.masterDoc().getFieldable("point.lat"), nullValue());
|
||||
MatcherAssert.assertThat(doc.masterDoc().getFieldable("point.lon"), nullValue());
|
||||
MatcherAssert.assertThat(doc.masterDoc().get("point.geohash"), equalTo(GeoHashUtils.encode(1.2, 1.3)));
|
||||
MatcherAssert.assertThat(doc.masterDoc().get("point"), notNullValue());
|
||||
MatcherAssert.assertThat(doc.rootDoc().getFieldable("point.lat"), nullValue());
|
||||
MatcherAssert.assertThat(doc.rootDoc().getFieldable("point.lon"), nullValue());
|
||||
MatcherAssert.assertThat(doc.rootDoc().get("point.geohash"), equalTo(GeoHashUtils.encode(1.2, 1.3)));
|
||||
MatcherAssert.assertThat(doc.rootDoc().get("point"), notNullValue());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -47,9 +47,9 @@ public class LatLonAndGeohashMappingGeoPointTests {
|
|||
.endObject()
|
||||
.copiedBytes());
|
||||
|
||||
assertThat(doc.masterDoc().getFieldable("point.lat"), notNullValue());
|
||||
assertThat(doc.masterDoc().getFieldable("point.lon"), notNullValue());
|
||||
assertThat(doc.masterDoc().get("point.geohash"), equalTo(GeoHashUtils.encode(1.2, 1.3)));
|
||||
assertThat(doc.rootDoc().getFieldable("point.lat"), notNullValue());
|
||||
assertThat(doc.rootDoc().getFieldable("point.lon"), notNullValue());
|
||||
assertThat(doc.rootDoc().get("point.geohash"), equalTo(GeoHashUtils.encode(1.2, 1.3)));
|
||||
}
|
||||
|
||||
@Test public void testLatLonInOneValue() throws Exception {
|
||||
|
@ -65,9 +65,9 @@ public class LatLonAndGeohashMappingGeoPointTests {
|
|||
.endObject()
|
||||
.copiedBytes());
|
||||
|
||||
assertThat(doc.masterDoc().getFieldable("point.lat"), notNullValue());
|
||||
assertThat(doc.masterDoc().getFieldable("point.lon"), notNullValue());
|
||||
assertThat(doc.masterDoc().get("point.geohash"), equalTo(GeoHashUtils.encode(1.2, 1.3)));
|
||||
assertThat(doc.rootDoc().getFieldable("point.lat"), notNullValue());
|
||||
assertThat(doc.rootDoc().getFieldable("point.lon"), notNullValue());
|
||||
assertThat(doc.rootDoc().get("point.geohash"), equalTo(GeoHashUtils.encode(1.2, 1.3)));
|
||||
}
|
||||
|
||||
@Test public void testGeoHashValue() throws Exception {
|
||||
|
@ -83,8 +83,8 @@ public class LatLonAndGeohashMappingGeoPointTests {
|
|||
.endObject()
|
||||
.copiedBytes());
|
||||
|
||||
assertThat(doc.masterDoc().getFieldable("point.lat"), notNullValue());
|
||||
assertThat(doc.masterDoc().getFieldable("point.lon"), notNullValue());
|
||||
assertThat(doc.masterDoc().get("point.geohash"), equalTo(GeoHashUtils.encode(1.2, 1.3)));
|
||||
assertThat(doc.rootDoc().getFieldable("point.lat"), notNullValue());
|
||||
assertThat(doc.rootDoc().getFieldable("point.lon"), notNullValue());
|
||||
assertThat(doc.rootDoc().get("point.geohash"), equalTo(GeoHashUtils.encode(1.2, 1.3)));
|
||||
}
|
||||
}
|
|
@ -48,12 +48,12 @@ public class LatLonMappingGeoPointTests {
|
|||
.endObject()
|
||||
.copiedBytes());
|
||||
|
||||
assertThat(doc.masterDoc().getFieldable("point.lat"), notNullValue());
|
||||
assertThat(doc.masterDoc().getFieldable("point.lat").getBinaryValue(), nullValue());
|
||||
assertThat(doc.masterDoc().getFieldable("point.lon"), notNullValue());
|
||||
assertThat(doc.masterDoc().getFieldable("point.lon").getBinaryValue(), nullValue());
|
||||
assertThat(doc.masterDoc().getFieldable("point.geohash"), nullValue());
|
||||
assertThat(doc.masterDoc().get("point"), equalTo("1.2,1.3"));
|
||||
assertThat(doc.rootDoc().getFieldable("point.lat"), notNullValue());
|
||||
assertThat(doc.rootDoc().getFieldable("point.lat").getBinaryValue(), nullValue());
|
||||
assertThat(doc.rootDoc().getFieldable("point.lon"), notNullValue());
|
||||
assertThat(doc.rootDoc().getFieldable("point.lon").getBinaryValue(), nullValue());
|
||||
assertThat(doc.rootDoc().getFieldable("point.geohash"), nullValue());
|
||||
assertThat(doc.rootDoc().get("point"), equalTo("1.2,1.3"));
|
||||
}
|
||||
|
||||
@Test public void testLatLonValuesStored() throws Exception {
|
||||
|
@ -69,12 +69,12 @@ public class LatLonMappingGeoPointTests {
|
|||
.endObject()
|
||||
.copiedBytes());
|
||||
|
||||
assertThat(doc.masterDoc().getFieldable("point.lat"), notNullValue());
|
||||
assertThat(doc.masterDoc().getFieldable("point.lat").getBinaryValue(), equalTo(Numbers.doubleToBytes(1.2)));
|
||||
assertThat(doc.masterDoc().getFieldable("point.lon"), notNullValue());
|
||||
assertThat(doc.masterDoc().getFieldable("point.lon").getBinaryValue(), equalTo(Numbers.doubleToBytes(1.3)));
|
||||
assertThat(doc.masterDoc().getFieldable("point.geohash"), nullValue());
|
||||
assertThat(doc.masterDoc().get("point"), equalTo("1.2,1.3"));
|
||||
assertThat(doc.rootDoc().getFieldable("point.lat"), notNullValue());
|
||||
assertThat(doc.rootDoc().getFieldable("point.lat").getBinaryValue(), equalTo(Numbers.doubleToBytes(1.2)));
|
||||
assertThat(doc.rootDoc().getFieldable("point.lon"), notNullValue());
|
||||
assertThat(doc.rootDoc().getFieldable("point.lon").getBinaryValue(), equalTo(Numbers.doubleToBytes(1.3)));
|
||||
assertThat(doc.rootDoc().getFieldable("point.geohash"), nullValue());
|
||||
assertThat(doc.rootDoc().get("point"), equalTo("1.2,1.3"));
|
||||
}
|
||||
|
||||
@Test public void testArrayLatLonValues() throws Exception {
|
||||
|
@ -93,14 +93,14 @@ public class LatLonMappingGeoPointTests {
|
|||
.endObject()
|
||||
.copiedBytes());
|
||||
|
||||
assertThat(doc.masterDoc().getFieldables("point.lat").length, equalTo(2));
|
||||
assertThat(doc.masterDoc().getFieldables("point.lon").length, equalTo(2));
|
||||
assertThat(doc.masterDoc().getFieldables("point.lat")[0].getBinaryValue(), equalTo(Numbers.doubleToBytes(1.2)));
|
||||
assertThat(doc.masterDoc().getFieldables("point.lon")[0].getBinaryValue(), equalTo(Numbers.doubleToBytes(1.3)));
|
||||
assertThat(doc.masterDoc().getFieldables("point")[0].stringValue(), equalTo("1.2,1.3"));
|
||||
assertThat(doc.masterDoc().getFieldables("point.lat")[1].getBinaryValue(), equalTo(Numbers.doubleToBytes(1.4)));
|
||||
assertThat(doc.masterDoc().getFieldables("point.lon")[1].getBinaryValue(), equalTo(Numbers.doubleToBytes(1.5)));
|
||||
assertThat(doc.masterDoc().getFieldables("point")[1].stringValue(), equalTo("1.4,1.5"));
|
||||
assertThat(doc.rootDoc().getFieldables("point.lat").length, equalTo(2));
|
||||
assertThat(doc.rootDoc().getFieldables("point.lon").length, equalTo(2));
|
||||
assertThat(doc.rootDoc().getFieldables("point.lat")[0].getBinaryValue(), equalTo(Numbers.doubleToBytes(1.2)));
|
||||
assertThat(doc.rootDoc().getFieldables("point.lon")[0].getBinaryValue(), equalTo(Numbers.doubleToBytes(1.3)));
|
||||
assertThat(doc.rootDoc().getFieldables("point")[0].stringValue(), equalTo("1.2,1.3"));
|
||||
assertThat(doc.rootDoc().getFieldables("point.lat")[1].getBinaryValue(), equalTo(Numbers.doubleToBytes(1.4)));
|
||||
assertThat(doc.rootDoc().getFieldables("point.lon")[1].getBinaryValue(), equalTo(Numbers.doubleToBytes(1.5)));
|
||||
assertThat(doc.rootDoc().getFieldables("point")[1].stringValue(), equalTo("1.4,1.5"));
|
||||
}
|
||||
|
||||
@Test public void testLatLonInOneValue() throws Exception {
|
||||
|
@ -116,9 +116,9 @@ public class LatLonMappingGeoPointTests {
|
|||
.endObject()
|
||||
.copiedBytes());
|
||||
|
||||
assertThat(doc.masterDoc().getFieldable("point.lat"), notNullValue());
|
||||
assertThat(doc.masterDoc().getFieldable("point.lon"), notNullValue());
|
||||
assertThat(doc.masterDoc().get("point"), equalTo("1.2,1.3"));
|
||||
assertThat(doc.rootDoc().getFieldable("point.lat"), notNullValue());
|
||||
assertThat(doc.rootDoc().getFieldable("point.lon"), notNullValue());
|
||||
assertThat(doc.rootDoc().get("point"), equalTo("1.2,1.3"));
|
||||
}
|
||||
|
||||
@Test public void testLatLonInOneValueStored() throws Exception {
|
||||
|
@ -134,11 +134,11 @@ public class LatLonMappingGeoPointTests {
|
|||
.endObject()
|
||||
.copiedBytes());
|
||||
|
||||
assertThat(doc.masterDoc().getFieldable("point.lat"), notNullValue());
|
||||
assertThat(doc.masterDoc().getFieldable("point.lat").getBinaryValue(), equalTo(Numbers.doubleToBytes(1.2)));
|
||||
assertThat(doc.masterDoc().getFieldable("point.lon"), notNullValue());
|
||||
assertThat(doc.masterDoc().getFieldable("point.lon").getBinaryValue(), equalTo(Numbers.doubleToBytes(1.3)));
|
||||
assertThat(doc.masterDoc().get("point"), equalTo("1.2,1.3"));
|
||||
assertThat(doc.rootDoc().getFieldable("point.lat"), notNullValue());
|
||||
assertThat(doc.rootDoc().getFieldable("point.lat").getBinaryValue(), equalTo(Numbers.doubleToBytes(1.2)));
|
||||
assertThat(doc.rootDoc().getFieldable("point.lon"), notNullValue());
|
||||
assertThat(doc.rootDoc().getFieldable("point.lon").getBinaryValue(), equalTo(Numbers.doubleToBytes(1.3)));
|
||||
assertThat(doc.rootDoc().get("point"), equalTo("1.2,1.3"));
|
||||
}
|
||||
|
||||
@Test public void testLatLonInOneValueArray() throws Exception {
|
||||
|
@ -157,14 +157,14 @@ public class LatLonMappingGeoPointTests {
|
|||
.endObject()
|
||||
.copiedBytes());
|
||||
|
||||
assertThat(doc.masterDoc().getFieldables("point.lat").length, equalTo(2));
|
||||
assertThat(doc.masterDoc().getFieldables("point.lon").length, equalTo(2));
|
||||
assertThat(doc.masterDoc().getFieldables("point.lat")[0].getBinaryValue(), equalTo(Numbers.doubleToBytes(1.2)));
|
||||
assertThat(doc.masterDoc().getFieldables("point.lon")[0].getBinaryValue(), equalTo(Numbers.doubleToBytes(1.3)));
|
||||
assertThat(doc.masterDoc().getFieldables("point")[0].stringValue(), equalTo("1.2,1.3"));
|
||||
assertThat(doc.masterDoc().getFieldables("point.lat")[1].getBinaryValue(), equalTo(Numbers.doubleToBytes(1.4)));
|
||||
assertThat(doc.masterDoc().getFieldables("point.lon")[1].getBinaryValue(), equalTo(Numbers.doubleToBytes(1.5)));
|
||||
assertThat(doc.masterDoc().getFieldables("point")[1].stringValue(), equalTo("1.4,1.5"));
|
||||
assertThat(doc.rootDoc().getFieldables("point.lat").length, equalTo(2));
|
||||
assertThat(doc.rootDoc().getFieldables("point.lon").length, equalTo(2));
|
||||
assertThat(doc.rootDoc().getFieldables("point.lat")[0].getBinaryValue(), equalTo(Numbers.doubleToBytes(1.2)));
|
||||
assertThat(doc.rootDoc().getFieldables("point.lon")[0].getBinaryValue(), equalTo(Numbers.doubleToBytes(1.3)));
|
||||
assertThat(doc.rootDoc().getFieldables("point")[0].stringValue(), equalTo("1.2,1.3"));
|
||||
assertThat(doc.rootDoc().getFieldables("point.lat")[1].getBinaryValue(), equalTo(Numbers.doubleToBytes(1.4)));
|
||||
assertThat(doc.rootDoc().getFieldables("point.lon")[1].getBinaryValue(), equalTo(Numbers.doubleToBytes(1.5)));
|
||||
assertThat(doc.rootDoc().getFieldables("point")[1].stringValue(), equalTo("1.4,1.5"));
|
||||
}
|
||||
|
||||
@Test public void testGeoHashValue() throws Exception {
|
||||
|
@ -180,9 +180,9 @@ public class LatLonMappingGeoPointTests {
|
|||
.endObject()
|
||||
.copiedBytes());
|
||||
|
||||
assertThat(doc.masterDoc().getFieldable("point.lat"), notNullValue());
|
||||
assertThat(doc.masterDoc().getFieldable("point.lon"), notNullValue());
|
||||
assertThat(doc.masterDoc().get("point"), notNullValue());
|
||||
assertThat(doc.rootDoc().getFieldable("point.lat"), notNullValue());
|
||||
assertThat(doc.rootDoc().getFieldable("point.lon"), notNullValue());
|
||||
assertThat(doc.rootDoc().get("point"), notNullValue());
|
||||
}
|
||||
|
||||
@Test public void testLonLatArray() throws Exception {
|
||||
|
@ -198,11 +198,11 @@ public class LatLonMappingGeoPointTests {
|
|||
.endObject()
|
||||
.copiedBytes());
|
||||
|
||||
assertThat(doc.masterDoc().getFieldable("point.lat"), notNullValue());
|
||||
assertThat(doc.masterDoc().getFieldable("point.lat").getBinaryValue(), nullValue());
|
||||
assertThat(doc.masterDoc().getFieldable("point.lon"), notNullValue());
|
||||
assertThat(doc.masterDoc().getFieldable("point.lon").getBinaryValue(), nullValue());
|
||||
assertThat(doc.masterDoc().get("point"), equalTo("1.2,1.3"));
|
||||
assertThat(doc.rootDoc().getFieldable("point.lat"), notNullValue());
|
||||
assertThat(doc.rootDoc().getFieldable("point.lat").getBinaryValue(), nullValue());
|
||||
assertThat(doc.rootDoc().getFieldable("point.lon"), notNullValue());
|
||||
assertThat(doc.rootDoc().getFieldable("point.lon").getBinaryValue(), nullValue());
|
||||
assertThat(doc.rootDoc().get("point"), equalTo("1.2,1.3"));
|
||||
}
|
||||
|
||||
@Test public void testLonLatArrayStored() throws Exception {
|
||||
|
@ -218,11 +218,11 @@ public class LatLonMappingGeoPointTests {
|
|||
.endObject()
|
||||
.copiedBytes());
|
||||
|
||||
assertThat(doc.masterDoc().getFieldable("point.lat"), notNullValue());
|
||||
assertThat(doc.masterDoc().getFieldable("point.lat").getBinaryValue(), equalTo(Numbers.doubleToBytes(1.2)));
|
||||
assertThat(doc.masterDoc().getFieldable("point.lon"), notNullValue());
|
||||
assertThat(doc.masterDoc().getFieldable("point.lon").getBinaryValue(), equalTo(Numbers.doubleToBytes(1.3)));
|
||||
assertThat(doc.masterDoc().get("point"), equalTo("1.2,1.3"));
|
||||
assertThat(doc.rootDoc().getFieldable("point.lat"), notNullValue());
|
||||
assertThat(doc.rootDoc().getFieldable("point.lat").getBinaryValue(), equalTo(Numbers.doubleToBytes(1.2)));
|
||||
assertThat(doc.rootDoc().getFieldable("point.lon"), notNullValue());
|
||||
assertThat(doc.rootDoc().getFieldable("point.lon").getBinaryValue(), equalTo(Numbers.doubleToBytes(1.3)));
|
||||
assertThat(doc.rootDoc().get("point"), equalTo("1.2,1.3"));
|
||||
}
|
||||
|
||||
@Test public void testLonLatArrayArrayStored() throws Exception {
|
||||
|
@ -241,13 +241,13 @@ public class LatLonMappingGeoPointTests {
|
|||
.endObject()
|
||||
.copiedBytes());
|
||||
|
||||
assertThat(doc.masterDoc().getFieldables("point.lat").length, equalTo(2));
|
||||
assertThat(doc.masterDoc().getFieldables("point.lon").length, equalTo(2));
|
||||
assertThat(doc.masterDoc().getFieldables("point.lat")[0].getBinaryValue(), equalTo(Numbers.doubleToBytes(1.2)));
|
||||
assertThat(doc.masterDoc().getFieldables("point.lon")[0].getBinaryValue(), equalTo(Numbers.doubleToBytes(1.3)));
|
||||
assertThat(doc.masterDoc().getFieldables("point")[0].stringValue(), equalTo("1.2,1.3"));
|
||||
assertThat(doc.masterDoc().getFieldables("point.lat")[1].getBinaryValue(), equalTo(Numbers.doubleToBytes(1.4)));
|
||||
assertThat(doc.masterDoc().getFieldables("point.lon")[1].getBinaryValue(), equalTo(Numbers.doubleToBytes(1.5)));
|
||||
assertThat(doc.masterDoc().getFieldables("point")[1].stringValue(), equalTo("1.4,1.5"));
|
||||
assertThat(doc.rootDoc().getFieldables("point.lat").length, equalTo(2));
|
||||
assertThat(doc.rootDoc().getFieldables("point.lon").length, equalTo(2));
|
||||
assertThat(doc.rootDoc().getFieldables("point.lat")[0].getBinaryValue(), equalTo(Numbers.doubleToBytes(1.2)));
|
||||
assertThat(doc.rootDoc().getFieldables("point.lon")[0].getBinaryValue(), equalTo(Numbers.doubleToBytes(1.3)));
|
||||
assertThat(doc.rootDoc().getFieldables("point")[0].stringValue(), equalTo("1.2,1.3"));
|
||||
assertThat(doc.rootDoc().getFieldables("point.lat")[1].getBinaryValue(), equalTo(Numbers.doubleToBytes(1.4)));
|
||||
assertThat(doc.rootDoc().getFieldables("point.lon")[1].getBinaryValue(), equalTo(Numbers.doubleToBytes(1.5)));
|
||||
assertThat(doc.rootDoc().getFieldables("point")[1].stringValue(), equalTo("1.4,1.5"));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -50,8 +50,8 @@ public class IndexTypeMapperTests {
|
|||
.endObject()
|
||||
.copiedBytes());
|
||||
|
||||
assertThat(doc.masterDoc().get("_index"), equalTo("test"));
|
||||
assertThat(doc.masterDoc().get("field"), equalTo("value"));
|
||||
assertThat(doc.rootDoc().get("_index"), equalTo("test"));
|
||||
assertThat(doc.rootDoc().get("field"), equalTo("value"));
|
||||
}
|
||||
|
||||
@Test public void explicitDisabledIndexMapperTests() throws Exception {
|
||||
|
@ -68,8 +68,8 @@ public class IndexTypeMapperTests {
|
|||
.endObject()
|
||||
.copiedBytes());
|
||||
|
||||
assertThat(doc.masterDoc().get("_index"), nullValue());
|
||||
assertThat(doc.masterDoc().get("field"), equalTo("value"));
|
||||
assertThat(doc.rootDoc().get("_index"), nullValue());
|
||||
assertThat(doc.rootDoc().get("field"), equalTo("value"));
|
||||
}
|
||||
|
||||
@Test public void defaultDisabledIndexMapperTests() throws Exception {
|
||||
|
@ -85,7 +85,7 @@ public class IndexTypeMapperTests {
|
|||
.endObject()
|
||||
.copiedBytes());
|
||||
|
||||
assertThat(doc.masterDoc().get("_index"), nullValue());
|
||||
assertThat(doc.masterDoc().get("field"), equalTo("value"));
|
||||
assertThat(doc.rootDoc().get("_index"), nullValue());
|
||||
assertThat(doc.rootDoc().get("field"), equalTo("value"));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package org.elasticsearch.index.mapper.lucene;
|
|||
|
||||
import org.apache.lucene.index.IndexReader;
|
||||
import org.apache.lucene.index.IndexWriter;
|
||||
import org.apache.lucene.index.IndexWriterConfig;
|
||||
import org.apache.lucene.search.IndexSearcher;
|
||||
import org.apache.lucene.search.TopDocs;
|
||||
import org.apache.lucene.store.RAMDirectory;
|
||||
|
@ -22,7 +23,7 @@ import static org.hamcrest.Matchers.*;
|
|||
public class DoubleIndexingDocTest {
|
||||
|
||||
@Test public void testDoubleIndexingSameDoc() throws Exception {
|
||||
IndexWriter writer = new IndexWriter(new RAMDirectory(), Lucene.STANDARD_ANALYZER, IndexWriter.MaxFieldLength.UNLIMITED);
|
||||
IndexWriter writer = new IndexWriter(new RAMDirectory(), new IndexWriterConfig(Lucene.VERSION, Lucene.STANDARD_ANALYZER));
|
||||
|
||||
String mapping = XContentFactory.jsonBuilder().startObject().startObject("type")
|
||||
.startObject("properties").endObject()
|
||||
|
@ -39,10 +40,10 @@ public class DoubleIndexingDocTest {
|
|||
.endObject()
|
||||
.copiedBytes());
|
||||
|
||||
writer.addDocument(doc.masterDoc(), doc.analyzer());
|
||||
writer.addDocument(doc.masterDoc(), doc.analyzer());
|
||||
writer.addDocument(doc.rootDoc(), doc.analyzer());
|
||||
writer.addDocument(doc.rootDoc(), doc.analyzer());
|
||||
|
||||
IndexReader reader = writer.getReader();
|
||||
IndexReader reader = IndexReader.open(writer, true);
|
||||
IndexSearcher searcher = new IndexSearcher(reader);
|
||||
|
||||
TopDocs topDocs = searcher.search(mapper.mappers().smartName("field1").mapper().fieldQuery("value1", null), 10);
|
||||
|
|
|
@ -42,7 +42,7 @@ public class MultiFieldTests {
|
|||
String mapping = copyToStringFromClasspath("/org/elasticsearch/index/mapper/multifield/test-mapping.json");
|
||||
DocumentMapper docMapper = MapperTests.newParser().parse(mapping);
|
||||
byte[] json = copyToBytesFromClasspath("/org/elasticsearch/index/mapper/multifield/test-data.json");
|
||||
Document doc = docMapper.parse(json).masterDoc();
|
||||
Document doc = docMapper.parse(json).rootDoc();
|
||||
|
||||
Fieldable f = doc.getFieldable("name");
|
||||
assertThat(f.name(), equalTo("name"));
|
||||
|
@ -88,7 +88,7 @@ public class MultiFieldTests {
|
|||
|
||||
|
||||
byte[] json = copyToBytesFromClasspath("/org/elasticsearch/index/mapper/multifield/test-data.json");
|
||||
Document doc = docMapper.parse(json).masterDoc();
|
||||
Document doc = docMapper.parse(json).rootDoc();
|
||||
|
||||
Fieldable f = doc.getFieldable("name");
|
||||
assertThat(f.name(), equalTo("name"));
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
package org.elasticsearch.index.mapper.multifield.merge;
|
||||
|
||||
import org.apache.lucene.document.Document;
|
||||
import org.apache.lucene.document.Field;
|
||||
import org.apache.lucene.document.Fieldable;
|
||||
import org.elasticsearch.index.mapper.DocumentMapper;
|
||||
import org.elasticsearch.index.mapper.DocumentMapperParser;
|
||||
import org.elasticsearch.index.mapper.MapperTests;
|
||||
|
@ -49,10 +49,10 @@ public class JavaMultiFieldMergeTests {
|
|||
assertThat(docMapper.mappers().fullName("name.indexed"), nullValue());
|
||||
|
||||
byte[] json = copyToBytesFromClasspath("/org/elasticsearch/index/mapper/multifield/merge/test-data.json");
|
||||
Document doc = docMapper.parse(json).masterDoc();
|
||||
Field f = doc.getField("name");
|
||||
Document doc = docMapper.parse(json).rootDoc();
|
||||
Fieldable f = doc.getFieldable("name");
|
||||
assertThat(f, notNullValue());
|
||||
f = doc.getField("name.indexed");
|
||||
f = doc.getFieldable("name.indexed");
|
||||
assertThat(f, nullValue());
|
||||
|
||||
|
||||
|
@ -73,10 +73,10 @@ public class JavaMultiFieldMergeTests {
|
|||
assertThat(docMapper.mappers().fullName("name.not_indexed3"), nullValue());
|
||||
|
||||
json = copyToBytesFromClasspath("/org/elasticsearch/index/mapper/multifield/merge/test-data.json");
|
||||
doc = docMapper.parse(json).masterDoc();
|
||||
f = doc.getField("name");
|
||||
doc = docMapper.parse(json).rootDoc();
|
||||
f = doc.getFieldable("name");
|
||||
assertThat(f, notNullValue());
|
||||
f = doc.getField("name.indexed");
|
||||
f = doc.getFieldable("name.indexed");
|
||||
assertThat(f, notNullValue());
|
||||
|
||||
mapping = copyToStringFromClasspath("/org/elasticsearch/index/mapper/multifield/merge/test-mapping3.json");
|
||||
|
|
|
@ -49,7 +49,7 @@ public class NullValueObjectMappingTests {
|
|||
.endObject()
|
||||
.copiedBytes());
|
||||
|
||||
assertThat(doc.masterDoc().get("value1"), equalTo("test1"));
|
||||
assertThat(doc.rootDoc().get("value1"), equalTo("test1"));
|
||||
|
||||
doc = defaultMapper.parse("type", "1", XContentFactory.jsonBuilder()
|
||||
.startObject()
|
||||
|
@ -58,7 +58,7 @@ public class NullValueObjectMappingTests {
|
|||
.endObject()
|
||||
.copiedBytes());
|
||||
|
||||
assertThat(doc.masterDoc().get("value1"), equalTo("test1"));
|
||||
assertThat(doc.rootDoc().get("value1"), equalTo("test1"));
|
||||
|
||||
doc = defaultMapper.parse("type", "1", XContentFactory.jsonBuilder()
|
||||
.startObject()
|
||||
|
@ -67,7 +67,7 @@ public class NullValueObjectMappingTests {
|
|||
.endObject()
|
||||
.copiedBytes());
|
||||
|
||||
assertThat(doc.masterDoc().get("obj1.field"), equalTo("value"));
|
||||
assertThat(doc.masterDoc().get("value1"), equalTo("test1"));
|
||||
assertThat(doc.rootDoc().get("obj1.field"), equalTo("value"));
|
||||
assertThat(doc.rootDoc().get("value1"), equalTo("test1"));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -48,7 +48,7 @@ public class ParentMappingTests {
|
|||
.endObject()
|
||||
.copiedBytes()).type("type").id("1"));
|
||||
|
||||
assertThat(doc.masterDoc().get("_parent"), equalTo(Uid.createUid("p_type", "1122")));
|
||||
assertThat(doc.rootDoc().get("_parent"), equalTo(Uid.createUid("p_type", "1122")));
|
||||
}
|
||||
|
||||
@Test public void parentNotSetInDocSetExternally() throws Exception {
|
||||
|
@ -63,7 +63,7 @@ public class ParentMappingTests {
|
|||
.endObject()
|
||||
.copiedBytes()).type("type").id("1").parent("1122"));
|
||||
|
||||
assertThat(doc.masterDoc().get("_parent"), equalTo(Uid.createUid("p_type", "1122")));
|
||||
assertThat(doc.rootDoc().get("_parent"), equalTo(Uid.createUid("p_type", "1122")));
|
||||
}
|
||||
|
||||
@Test public void parentSetInDocSetExternally() throws Exception {
|
||||
|
@ -79,6 +79,6 @@ public class ParentMappingTests {
|
|||
.endObject()
|
||||
.copiedBytes()).type("type").id("1").parent("1122"));
|
||||
|
||||
assertThat(doc.masterDoc().get("_parent"), equalTo(Uid.createUid("p_type", "1122")));
|
||||
assertThat(doc.rootDoc().get("_parent"), equalTo(Uid.createUid("p_type", "1122")));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -45,7 +45,7 @@ public class RoutingTypeMapperTests {
|
|||
.endObject()
|
||||
.copiedBytes()).type("type").id("1").routing("routing_value"));
|
||||
|
||||
assertThat(doc.masterDoc().get("_routing"), equalTo("routing_value"));
|
||||
assertThat(doc.masterDoc().get("field"), equalTo("value"));
|
||||
assertThat(doc.rootDoc().get("_routing"), equalTo("routing_value"));
|
||||
assertThat(doc.rootDoc().get("field"), equalTo("value"));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,14 +46,14 @@ public class SimpleMapperTests {
|
|||
).sourceField(source()).build(mapperParser);
|
||||
|
||||
byte[] json = copyToBytesFromClasspath("/org/elasticsearch/index/mapper/simple/test1.json");
|
||||
Document doc = docMapper.parse("person", "1", json).masterDoc();
|
||||
Document doc = docMapper.parse("person", "1", json).rootDoc();
|
||||
|
||||
assertThat((double) doc.getBoost(), closeTo(3.7, 0.01));
|
||||
assertThat(doc.get(docMapper.mappers().name("first").mapper().names().indexName()), equalTo("shay"));
|
||||
assertThat(docMapper.mappers().name("first").mapper().names().fullName(), equalTo("name.first"));
|
||||
// System.out.println("Document: " + doc);
|
||||
// System.out.println("Json: " + docMapper.sourceMapper().value(doc));
|
||||
doc = docMapper.parse(json).masterDoc();
|
||||
doc = docMapper.parse(json).rootDoc();
|
||||
// System.out.println("Document: " + doc);
|
||||
// System.out.println("Json: " + docMapper.sourceMapper().value(doc));
|
||||
}
|
||||
|
@ -66,7 +66,7 @@ public class SimpleMapperTests {
|
|||
// reparse it
|
||||
DocumentMapper builtDocMapper = MapperTests.newParser().parse(builtMapping);
|
||||
byte[] json = copyToBytesFromClasspath("/org/elasticsearch/index/mapper/simple/test1.json");
|
||||
Document doc = builtDocMapper.parse(json).masterDoc();
|
||||
Document doc = builtDocMapper.parse(json).rootDoc();
|
||||
assertThat(doc.get(docMapper.uidMapper().names().indexName()), equalTo(Uid.createUid("person", "1")));
|
||||
assertThat((double) doc.getBoost(), closeTo(3.7, 0.01));
|
||||
assertThat(doc.get(docMapper.mappers().name("first").mapper().names().indexName()), equalTo("shay"));
|
||||
|
@ -81,7 +81,7 @@ public class SimpleMapperTests {
|
|||
assertThat((String) docMapper.meta().get("param1"), equalTo("value1"));
|
||||
|
||||
byte[] json = copyToBytesFromClasspath("/org/elasticsearch/index/mapper/simple/test1.json");
|
||||
Document doc = docMapper.parse(json).masterDoc();
|
||||
Document doc = docMapper.parse(json).rootDoc();
|
||||
assertThat(doc.get(docMapper.uidMapper().names().indexName()), equalTo(Uid.createUid("person", "1")));
|
||||
assertThat((double) doc.getBoost(), closeTo(3.7, 0.01));
|
||||
assertThat(doc.get(docMapper.mappers().name("first").mapper().names().indexName()), equalTo("shay"));
|
||||
|
@ -93,7 +93,7 @@ public class SimpleMapperTests {
|
|||
String mapping = copyToStringFromClasspath("/org/elasticsearch/index/mapper/simple/test-mapping.json");
|
||||
DocumentMapper docMapper = MapperTests.newParser().parse(mapping);
|
||||
byte[] json = copyToBytesFromClasspath("/org/elasticsearch/index/mapper/simple/test1-notype-noid.json");
|
||||
Document doc = docMapper.parse("person", "1", json).masterDoc();
|
||||
Document doc = docMapper.parse("person", "1", json).rootDoc();
|
||||
assertThat(doc.get(docMapper.uidMapper().names().indexName()), equalTo(Uid.createUid("person", "1")));
|
||||
assertThat((double) doc.getBoost(), closeTo(3.7, 0.01));
|
||||
assertThat(doc.get(docMapper.mappers().name("first").mapper().names().indexName()), equalTo("shay"));
|
||||
|
|
|
@ -45,8 +45,8 @@ public class SizeMappingTests {
|
|||
.copiedBytes();
|
||||
ParsedDocument doc = docMapper.parse(SourceToParse.source(source).type("type").id("1"));
|
||||
|
||||
assertThat(doc.masterDoc().getFieldable("_size").isStored(), equalTo(false));
|
||||
assertThat(doc.masterDoc().getFieldable("_size").tokenStreamValue(), notNullValue());
|
||||
assertThat(doc.rootDoc().getFieldable("_size").isStored(), equalTo(false));
|
||||
assertThat(doc.rootDoc().getFieldable("_size").tokenStreamValue(), notNullValue());
|
||||
}
|
||||
|
||||
@Test public void testSizeEnabledAndStored() throws Exception {
|
||||
|
@ -62,8 +62,8 @@ public class SizeMappingTests {
|
|||
.copiedBytes();
|
||||
ParsedDocument doc = docMapper.parse(SourceToParse.source(source).type("type").id("1"));
|
||||
|
||||
assertThat(doc.masterDoc().getFieldable("_size").isStored(), equalTo(true));
|
||||
assertThat(doc.masterDoc().getFieldable("_size").tokenStreamValue(), notNullValue());
|
||||
assertThat(doc.rootDoc().getFieldable("_size").isStored(), equalTo(true));
|
||||
assertThat(doc.rootDoc().getFieldable("_size").tokenStreamValue(), notNullValue());
|
||||
}
|
||||
|
||||
@Test public void testSizeDisabled() throws Exception {
|
||||
|
@ -79,7 +79,7 @@ public class SizeMappingTests {
|
|||
.copiedBytes();
|
||||
ParsedDocument doc = docMapper.parse(SourceToParse.source(source).type("type").id("1"));
|
||||
|
||||
assertThat(doc.masterDoc().getFieldable("_size"), nullValue());
|
||||
assertThat(doc.rootDoc().getFieldable("_size"), nullValue());
|
||||
}
|
||||
|
||||
@Test public void testSizeNotSet() throws Exception {
|
||||
|
@ -94,6 +94,6 @@ public class SizeMappingTests {
|
|||
.copiedBytes();
|
||||
ParsedDocument doc = docMapper.parse(SourceToParse.source(source).type("type").id("1"));
|
||||
|
||||
assertThat(doc.masterDoc().getFieldable("_size"), nullValue());
|
||||
assertThat(doc.rootDoc().getFieldable("_size"), nullValue());
|
||||
}
|
||||
}
|
|
@ -46,7 +46,7 @@ public class CompressSourceMappingTests {
|
|||
.field("field2", "value2")
|
||||
.endObject().copiedBytes());
|
||||
|
||||
assertThat(LZF.isCompressed(doc.masterDoc().getBinaryValue("_source")), equalTo(false));
|
||||
assertThat(LZF.isCompressed(doc.rootDoc().getBinaryValue("_source")), equalTo(false));
|
||||
}
|
||||
|
||||
@Test public void testCompressEnabled() throws Exception {
|
||||
|
@ -61,7 +61,7 @@ public class CompressSourceMappingTests {
|
|||
.field("field2", "value2")
|
||||
.endObject().copiedBytes());
|
||||
|
||||
assertThat(LZF.isCompressed(doc.masterDoc().getBinaryValue("_source")), equalTo(true));
|
||||
assertThat(LZF.isCompressed(doc.rootDoc().getBinaryValue("_source")), equalTo(true));
|
||||
}
|
||||
|
||||
@Test public void testCompressThreshold() throws Exception {
|
||||
|
@ -75,7 +75,7 @@ public class CompressSourceMappingTests {
|
|||
.field("field1", "value1")
|
||||
.endObject().copiedBytes());
|
||||
|
||||
assertThat(LZF.isCompressed(doc.masterDoc().getBinaryValue("_source")), equalTo(false));
|
||||
assertThat(LZF.isCompressed(doc.rootDoc().getBinaryValue("_source")), equalTo(false));
|
||||
|
||||
doc = documentMapper.parse("type", "1", XContentFactory.jsonBuilder().startObject()
|
||||
.field("field1", "value1")
|
||||
|
@ -85,6 +85,6 @@ public class CompressSourceMappingTests {
|
|||
.field("field2", "value2 xxxxxxxxxxxxxx yyyyyyyyyyyyyyyyyyy zzzzzzzzzzzzzzzzz")
|
||||
.endObject().copiedBytes());
|
||||
|
||||
assertThat(LZF.isCompressed(doc.masterDoc().getBinaryValue("_source")), equalTo(true));
|
||||
assertThat(LZF.isCompressed(doc.rootDoc().getBinaryValue("_source")), equalTo(true));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,9 +46,9 @@ public class ParseDocumentTypeLevelsTests {
|
|||
.endObject()
|
||||
.copiedBytes());
|
||||
|
||||
assertThat(doc.masterDoc().get("test1"), equalTo("value1"));
|
||||
assertThat(doc.masterDoc().get("test2"), equalTo("value2"));
|
||||
assertThat(doc.masterDoc().get("inner.inner_field"), equalTo("inner_value"));
|
||||
assertThat(doc.rootDoc().get("test1"), equalTo("value1"));
|
||||
assertThat(doc.rootDoc().get("test2"), equalTo("value2"));
|
||||
assertThat(doc.rootDoc().get("inner.inner_field"), equalTo("inner_value"));
|
||||
}
|
||||
|
||||
@Test public void testTypeLevel() throws Exception {
|
||||
|
@ -64,9 +64,9 @@ public class ParseDocumentTypeLevelsTests {
|
|||
.endObject().endObject()
|
||||
.copiedBytes());
|
||||
|
||||
assertThat(doc.masterDoc().get("test1"), equalTo("value1"));
|
||||
assertThat(doc.masterDoc().get("test2"), equalTo("value2"));
|
||||
assertThat(doc.masterDoc().get("inner.inner_field"), equalTo("inner_value"));
|
||||
assertThat(doc.rootDoc().get("test1"), equalTo("value1"));
|
||||
assertThat(doc.rootDoc().get("test2"), equalTo("value2"));
|
||||
assertThat(doc.rootDoc().get("inner.inner_field"), equalTo("inner_value"));
|
||||
}
|
||||
|
||||
@Test public void testNoLevelWithFieldTypeAsValue() throws Exception {
|
||||
|
@ -83,10 +83,10 @@ public class ParseDocumentTypeLevelsTests {
|
|||
.endObject()
|
||||
.copiedBytes());
|
||||
|
||||
assertThat(doc.masterDoc().get("type"), equalTo("value_type"));
|
||||
assertThat(doc.masterDoc().get("test1"), equalTo("value1"));
|
||||
assertThat(doc.masterDoc().get("test2"), equalTo("value2"));
|
||||
assertThat(doc.masterDoc().get("inner.inner_field"), equalTo("inner_value"));
|
||||
assertThat(doc.rootDoc().get("type"), equalTo("value_type"));
|
||||
assertThat(doc.rootDoc().get("test1"), equalTo("value1"));
|
||||
assertThat(doc.rootDoc().get("test2"), equalTo("value2"));
|
||||
assertThat(doc.rootDoc().get("inner.inner_field"), equalTo("inner_value"));
|
||||
}
|
||||
|
||||
@Test public void testTypeLevelWithFieldTypeAsValue() throws Exception {
|
||||
|
@ -103,10 +103,10 @@ public class ParseDocumentTypeLevelsTests {
|
|||
.endObject().endObject()
|
||||
.copiedBytes());
|
||||
|
||||
assertThat(doc.masterDoc().get("type"), equalTo("value_type"));
|
||||
assertThat(doc.masterDoc().get("test1"), equalTo("value1"));
|
||||
assertThat(doc.masterDoc().get("test2"), equalTo("value2"));
|
||||
assertThat(doc.masterDoc().get("inner.inner_field"), equalTo("inner_value"));
|
||||
assertThat(doc.rootDoc().get("type"), equalTo("value_type"));
|
||||
assertThat(doc.rootDoc().get("test1"), equalTo("value1"));
|
||||
assertThat(doc.rootDoc().get("test2"), equalTo("value2"));
|
||||
assertThat(doc.rootDoc().get("inner.inner_field"), equalTo("inner_value"));
|
||||
}
|
||||
|
||||
@Test public void testNoLevelWithFieldTypeAsObject() throws Exception {
|
||||
|
@ -124,9 +124,9 @@ public class ParseDocumentTypeLevelsTests {
|
|||
.copiedBytes());
|
||||
|
||||
// in this case, we analyze the type object as the actual document, and ignore the other same level fields
|
||||
assertThat(doc.masterDoc().get("type_field"), equalTo("type_value"));
|
||||
assertThat(doc.masterDoc().get("test1"), nullValue());
|
||||
assertThat(doc.masterDoc().get("test2"), nullValue());
|
||||
assertThat(doc.rootDoc().get("type_field"), equalTo("type_value"));
|
||||
assertThat(doc.rootDoc().get("test1"), nullValue());
|
||||
assertThat(doc.rootDoc().get("test2"), nullValue());
|
||||
}
|
||||
|
||||
@Test public void testTypeLevelWithFieldTypeAsObject() throws Exception {
|
||||
|
@ -143,10 +143,10 @@ public class ParseDocumentTypeLevelsTests {
|
|||
.endObject().endObject()
|
||||
.copiedBytes());
|
||||
|
||||
assertThat(doc.masterDoc().get("type.type_field"), equalTo("type_value"));
|
||||
assertThat(doc.masterDoc().get("test1"), equalTo("value1"));
|
||||
assertThat(doc.masterDoc().get("test2"), equalTo("value2"));
|
||||
assertThat(doc.masterDoc().get("inner.inner_field"), equalTo("inner_value"));
|
||||
assertThat(doc.rootDoc().get("type.type_field"), equalTo("type_value"));
|
||||
assertThat(doc.rootDoc().get("test1"), equalTo("value1"));
|
||||
assertThat(doc.rootDoc().get("test2"), equalTo("value2"));
|
||||
assertThat(doc.rootDoc().get("inner.inner_field"), equalTo("inner_value"));
|
||||
}
|
||||
|
||||
@Test public void testNoLevelWithFieldTypeAsValueNotFirst() throws Exception {
|
||||
|
@ -163,10 +163,10 @@ public class ParseDocumentTypeLevelsTests {
|
|||
.endObject().endObject()
|
||||
.copiedBytes());
|
||||
|
||||
assertThat(doc.masterDoc().get("type"), equalTo("value_type"));
|
||||
assertThat(doc.masterDoc().get("test1"), equalTo("value1"));
|
||||
assertThat(doc.masterDoc().get("test2"), equalTo("value2"));
|
||||
assertThat(doc.masterDoc().get("inner.inner_field"), equalTo("inner_value"));
|
||||
assertThat(doc.rootDoc().get("type"), equalTo("value_type"));
|
||||
assertThat(doc.rootDoc().get("test1"), equalTo("value1"));
|
||||
assertThat(doc.rootDoc().get("test2"), equalTo("value2"));
|
||||
assertThat(doc.rootDoc().get("inner.inner_field"), equalTo("inner_value"));
|
||||
}
|
||||
|
||||
@Test public void testTypeLevelWithFieldTypeAsValueNotFirst() throws Exception {
|
||||
|
@ -183,10 +183,10 @@ public class ParseDocumentTypeLevelsTests {
|
|||
.endObject().endObject()
|
||||
.copiedBytes());
|
||||
|
||||
assertThat(doc.masterDoc().get("type"), equalTo("value_type"));
|
||||
assertThat(doc.masterDoc().get("test1"), equalTo("value1"));
|
||||
assertThat(doc.masterDoc().get("test2"), equalTo("value2"));
|
||||
assertThat(doc.masterDoc().get("inner.inner_field"), equalTo("inner_value"));
|
||||
assertThat(doc.rootDoc().get("type"), equalTo("value_type"));
|
||||
assertThat(doc.rootDoc().get("test1"), equalTo("value1"));
|
||||
assertThat(doc.rootDoc().get("test2"), equalTo("value2"));
|
||||
assertThat(doc.rootDoc().get("inner.inner_field"), equalTo("inner_value"));
|
||||
}
|
||||
|
||||
@Test public void testNoLevelWithFieldTypeAsObjectNotFirst() throws Exception {
|
||||
|
@ -204,10 +204,10 @@ public class ParseDocumentTypeLevelsTests {
|
|||
.copiedBytes());
|
||||
|
||||
// when the type is not the first one, we don't confuse it...
|
||||
assertThat(doc.masterDoc().get("type.type_field"), equalTo("type_value"));
|
||||
assertThat(doc.masterDoc().get("test1"), equalTo("value1"));
|
||||
assertThat(doc.masterDoc().get("test2"), equalTo("value2"));
|
||||
assertThat(doc.masterDoc().get("inner.inner_field"), equalTo("inner_value"));
|
||||
assertThat(doc.rootDoc().get("type.type_field"), equalTo("type_value"));
|
||||
assertThat(doc.rootDoc().get("test1"), equalTo("value1"));
|
||||
assertThat(doc.rootDoc().get("test2"), equalTo("value2"));
|
||||
assertThat(doc.rootDoc().get("inner.inner_field"), equalTo("inner_value"));
|
||||
}
|
||||
|
||||
@Test public void testTypeLevelWithFieldTypeAsObjectNotFirst() throws Exception {
|
||||
|
@ -224,9 +224,9 @@ public class ParseDocumentTypeLevelsTests {
|
|||
.endObject().endObject()
|
||||
.copiedBytes());
|
||||
|
||||
assertThat(doc.masterDoc().get("type.type_field"), equalTo("type_value"));
|
||||
assertThat(doc.masterDoc().get("test1"), equalTo("value1"));
|
||||
assertThat(doc.masterDoc().get("test2"), equalTo("value2"));
|
||||
assertThat(doc.masterDoc().get("inner.inner_field"), equalTo("inner_value"));
|
||||
assertThat(doc.rootDoc().get("type.type_field"), equalTo("type_value"));
|
||||
assertThat(doc.rootDoc().get("test1"), equalTo("value1"));
|
||||
assertThat(doc.rootDoc().get("test2"), equalTo("value2"));
|
||||
assertThat(doc.rootDoc().get("inner.inner_field"), equalTo("inner_value"));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -53,7 +53,7 @@ public class SimpleAttachmentMapperTests {
|
|||
|
||||
byte[] json = jsonBuilder().startObject().field("_id", 1).field("file", html).endObject().copiedBytes();
|
||||
|
||||
Document doc = docMapper.parse(json).masterDoc();
|
||||
Document doc = docMapper.parse(json).rootDoc();
|
||||
|
||||
assertThat(doc.get(docMapper.mappers().smartName("file.title").mapper().names().indexName()), equalTo("XHTML test document"));
|
||||
assertThat(doc.get(docMapper.mappers().smartName("file").mapper().names().indexName()), containsString("This document tests the ability of Apache Tika to extract content"));
|
||||
|
@ -64,7 +64,7 @@ public class SimpleAttachmentMapperTests {
|
|||
|
||||
json = jsonBuilder().startObject().field("_id", 1).field("file", html).endObject().copiedBytes();
|
||||
|
||||
doc = docMapper.parse(json).masterDoc();
|
||||
doc = docMapper.parse(json).rootDoc();
|
||||
|
||||
assertThat(doc.get(docMapper.mappers().smartName("file.title").mapper().names().indexName()), equalTo("XHTML test document"));
|
||||
assertThat(doc.get(docMapper.mappers().smartName("file").mapper().names().indexName()), containsString("This document tests the ability of Apache Tika to extract content"));
|
||||
|
|
Loading…
Reference in New Issue