Fix compile errors after elasticsearch-core master refactorings and multi-module builds
This commit is contained in:
parent
cf97e14ff0
commit
f743ebb87f
|
@ -21,17 +21,19 @@ package org.elasticsearch.index.mapper.attachment;
|
|||
|
||||
import org.apache.lucene.document.Field;
|
||||
import org.apache.lucene.document.FieldType;
|
||||
import org.apache.lucene.index.IndexOptions;
|
||||
import org.apache.lucene.util.CollectionUtil;
|
||||
import org.apache.lucene.util.Constants;
|
||||
import org.apache.tika.Tika;
|
||||
import org.apache.tika.language.LanguageIdentifier;
|
||||
import org.apache.tika.metadata.Metadata;
|
||||
import org.elasticsearch.Version;
|
||||
import org.elasticsearch.common.collect.Iterators;
|
||||
import org.elasticsearch.common.collect.Lists;
|
||||
import org.elasticsearch.common.Nullable;
|
||||
import org.elasticsearch.common.io.stream.StreamInput;
|
||||
import org.elasticsearch.common.logging.ESLogger;
|
||||
import org.elasticsearch.common.logging.ESLoggerFactory;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.util.CollectionUtils;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.index.fielddata.FieldDataType;
|
||||
|
@ -39,10 +41,7 @@ import org.elasticsearch.index.mapper.*;
|
|||
import org.elasticsearch.index.mapper.core.AbstractFieldMapper;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
|
||||
import static org.elasticsearch.index.mapper.MapperBuilders.*;
|
||||
import static org.elasticsearch.index.mapper.core.TypeParsers.parseMultiField;
|
||||
|
@ -90,6 +89,24 @@ public class AttachmentMapper extends AbstractFieldMapper {
|
|||
public static final String LANGUAGE = "language";
|
||||
}
|
||||
|
||||
static final class AttachmentFieldType extends MappedFieldType {
|
||||
public AttachmentFieldType() {
|
||||
super(AbstractFieldMapper.Defaults.FIELD_TYPE);
|
||||
}
|
||||
|
||||
protected AttachmentFieldType(AttachmentMapper.AttachmentFieldType ref) {
|
||||
super(ref);
|
||||
}
|
||||
|
||||
public AttachmentMapper.AttachmentFieldType clone() {
|
||||
return new AttachmentMapper.AttachmentFieldType(this);
|
||||
}
|
||||
|
||||
public String value(Object value) {
|
||||
return value == null?null:value.toString();
|
||||
}
|
||||
}
|
||||
|
||||
public static class Builder extends AbstractFieldMapper.Builder<Builder, AttachmentMapper> {
|
||||
|
||||
private ContentPath.Type pathType = Defaults.PATH_TYPE;
|
||||
|
@ -119,7 +136,7 @@ public class AttachmentMapper extends AbstractFieldMapper {
|
|||
private Mapper.Builder languageBuilder = stringField(FieldNames.LANGUAGE);
|
||||
|
||||
public Builder(String name) {
|
||||
super(name, new FieldType(AbstractFieldMapper.Defaults.FIELD_TYPE));
|
||||
super(name, new AttachmentFieldType());
|
||||
this.builder = this;
|
||||
this.contentBuilder = stringField(FieldNames.CONTENT);
|
||||
}
|
||||
|
@ -226,10 +243,24 @@ public class AttachmentMapper extends AbstractFieldMapper {
|
|||
if (langDetect == null) {
|
||||
langDetect = Boolean.FALSE;
|
||||
}
|
||||
MappedFieldType defaultFieldType = AbstractFieldMapper.Defaults.FIELD_TYPE.clone();
|
||||
if(this.fieldType.indexOptions() != IndexOptions.NONE && !this.fieldType.tokenized()) {
|
||||
defaultFieldType.setOmitNorms(true);
|
||||
defaultFieldType.setIndexOptions(IndexOptions.DOCS);
|
||||
if(!this.omitNormsSet && this.fieldType.boost() == 1.0F) {
|
||||
this.fieldType.setOmitNorms(true);
|
||||
}
|
||||
|
||||
return new AttachmentMapper(buildNames(context), pathType, defaultIndexedChars, ignoreErrors, langDetect, contentMapper,
|
||||
if(!this.indexOptionsSet) {
|
||||
this.fieldType.setIndexOptions(IndexOptions.DOCS);
|
||||
}
|
||||
}
|
||||
|
||||
defaultFieldType.freeze();
|
||||
this.setupFieldType(context);
|
||||
return new AttachmentMapper(this.fieldType, pathType, defaultIndexedChars, ignoreErrors, langDetect, contentMapper,
|
||||
dateMapper, titleMapper, nameMapper, authorMapper, keywordsMapper, contentTypeMapper, contentLength,
|
||||
language, context.indexSettings(), multiFieldsBuilder.build(this, context), copyTo);
|
||||
language, this.fieldDataSettings, context.indexSettings(), multiFieldsBuilder.build(this, context), copyTo);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -371,13 +402,12 @@ public class AttachmentMapper extends AbstractFieldMapper {
|
|||
|
||||
private final FieldMapper languageMapper;
|
||||
|
||||
public AttachmentMapper(Names names, ContentPath.Type pathType, int defaultIndexedChars, Boolean ignoreErrors,
|
||||
public AttachmentMapper(MappedFieldType type, ContentPath.Type pathType, int defaultIndexedChars, Boolean ignoreErrors,
|
||||
Boolean defaultLangDetect, FieldMapper contentMapper,
|
||||
FieldMapper dateMapper, FieldMapper titleMapper, FieldMapper nameMapper, FieldMapper authorMapper,
|
||||
FieldMapper keywordsMapper, FieldMapper contentTypeMapper, FieldMapper contentLengthMapper,
|
||||
FieldMapper languageMapper, Settings indexSettings, MultiFields multiFields, CopyTo copyTo) {
|
||||
super(names, 1.0f, AbstractFieldMapper.Defaults.FIELD_TYPE, false, null, null, null, null, null,
|
||||
indexSettings, multiFields, copyTo);
|
||||
FieldMapper languageMapper, @Nullable Settings fieldDataSettings, Settings indexSettings, MultiFields multiFields, CopyTo copyTo) {
|
||||
super(type, false, fieldDataSettings, indexSettings, multiFields, copyTo);
|
||||
this.pathType = pathType;
|
||||
this.defaultIndexedChars = defaultIndexedChars;
|
||||
this.ignoreErrors = ignoreErrors;
|
||||
|
@ -394,12 +424,7 @@ public class AttachmentMapper extends AbstractFieldMapper {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Object value(Object value) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FieldType defaultFieldType() {
|
||||
public MappedFieldType defaultFieldType() {
|
||||
return AbstractFieldMapper.Defaults.FIELD_TYPE;
|
||||
}
|
||||
|
||||
|
@ -611,7 +636,7 @@ public class AttachmentMapper extends AbstractFieldMapper {
|
|||
|
||||
@Override
|
||||
public Iterator<Mapper> iterator() {
|
||||
List<FieldMapper> extras = Lists.newArrayList(
|
||||
List<FieldMapper> extras = Arrays.asList(
|
||||
contentMapper,
|
||||
dateMapper,
|
||||
titleMapper,
|
||||
|
@ -621,7 +646,7 @@ public class AttachmentMapper extends AbstractFieldMapper {
|
|||
contentTypeMapper,
|
||||
contentLengthMapper,
|
||||
languageMapper);
|
||||
return Iterators.concat(super.iterator(), extras.iterator());
|
||||
return CollectionUtils.concat(super.iterator(), extras.iterator());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -22,10 +22,9 @@ package org.elasticsearch.plugin.mapper.attachments;
|
|||
import org.elasticsearch.common.inject.Module;
|
||||
import org.elasticsearch.plugins.AbstractPlugin;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
|
||||
import static org.elasticsearch.common.collect.Lists.newArrayList;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
@ -43,7 +42,7 @@ public class MapperAttachmentsPlugin extends AbstractPlugin {
|
|||
|
||||
@Override
|
||||
public Collection<Class<? extends Module>> indexModules() {
|
||||
Collection<Class<? extends Module>> modules = newArrayList();
|
||||
Collection<Class<? extends Module>> modules = new ArrayList<>();
|
||||
modules.add(AttachmentsIndexModule.class);
|
||||
return modules;
|
||||
}
|
||||
|
|
|
@ -19,11 +19,11 @@
|
|||
|
||||
package org.elasticsearch.index.mapper.attachment.test.standalone;
|
||||
|
||||
import org.apache.commons.cli.CommandLine;
|
||||
import org.elasticsearch.common.bytes.BytesReference;
|
||||
import org.elasticsearch.common.cli.CliTool;
|
||||
import org.elasticsearch.common.cli.CliToolConfig;
|
||||
import org.elasticsearch.common.cli.Terminal;
|
||||
import org.elasticsearch.common.cli.commons.CommandLine;
|
||||
import org.elasticsearch.common.io.PathUtils;
|
||||
import org.elasticsearch.common.io.stream.BytesStreamOutput;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
|
@ -113,7 +113,7 @@ public class StandaloneRunner extends CliTool {
|
|||
|
||||
terminal.println("## Extracted text");
|
||||
terminal.println("--------------------- BEGIN -----------------------");
|
||||
terminal.println("%s", doc.get(docMapper.mappers().getMapper("file").names().indexName()));
|
||||
terminal.println("%s", doc.get(docMapper.mappers().getMapper("file").fieldType().names().indexName()));
|
||||
terminal.println("---------------------- END ------------------------");
|
||||
terminal.println("## Metadata");
|
||||
printMetadataContent(doc, AttachmentMapper.FieldNames.AUTHOR);
|
||||
|
@ -129,7 +129,7 @@ public class StandaloneRunner extends CliTool {
|
|||
}
|
||||
|
||||
private void printMetadataContent(ParseContext.Document doc, String field) {
|
||||
terminal.println("- %s: %s", field, doc.get(docMapper.mappers().getMapper("file." + field).names().indexName()));
|
||||
terminal.println("- %s: %s", field, doc.get(docMapper.mappers().getMapper("file." + field).fieldType().names().indexName()));
|
||||
}
|
||||
|
||||
public static byte[] copyToBytes(Path path) throws IOException {
|
||||
|
|
|
@ -60,19 +60,19 @@ public class EncryptedDocMapperTest extends AttachmentUnitTestCase {
|
|||
.endObject().bytes();
|
||||
|
||||
ParseContext.Document doc = docMapper.parse("person", "1", json).rootDoc();
|
||||
assertThat(doc.get(docMapper.mappers().getMapper("file1.content").names().indexName()), containsString("World"));
|
||||
assertThat(doc.get(docMapper.mappers().getMapper("file1.title").names().indexName()), equalTo("Hello"));
|
||||
assertThat(doc.get(docMapper.mappers().getMapper("file1.author").names().indexName()), equalTo("kimchy"));
|
||||
assertThat(doc.get(docMapper.mappers().getMapper("file1.keywords").names().indexName()), equalTo("elasticsearch,cool,bonsai"));
|
||||
assertThat(doc.get(docMapper.mappers().getMapper("file1.content_type").names().indexName()), equalTo("text/html; charset=ISO-8859-1"));
|
||||
assertThat(doc.getField(docMapper.mappers().getMapper("file1.content_length").names().indexName()).numericValue().longValue(), is(344L));
|
||||
assertThat(doc.get(docMapper.mappers().getMapper("file1.content").fieldType().names().indexName()), containsString("World"));
|
||||
assertThat(doc.get(docMapper.mappers().getMapper("file1.title").fieldType().names().indexName()), equalTo("Hello"));
|
||||
assertThat(doc.get(docMapper.mappers().getMapper("file1.author").fieldType().names().indexName()), equalTo("kimchy"));
|
||||
assertThat(doc.get(docMapper.mappers().getMapper("file1.keywords").fieldType().names().indexName()), equalTo("elasticsearch,cool,bonsai"));
|
||||
assertThat(doc.get(docMapper.mappers().getMapper("file1.content_type").fieldType().names().indexName()), equalTo("text/html; charset=ISO-8859-1"));
|
||||
assertThat(doc.getField(docMapper.mappers().getMapper("file1.content_length").fieldType().names().indexName()).numericValue().longValue(), is(344L));
|
||||
|
||||
assertThat(doc.get(docMapper.mappers().getMapper("file2").names().indexName()), nullValue());
|
||||
assertThat(doc.get(docMapper.mappers().getMapper("file2.title").names().indexName()), nullValue());
|
||||
assertThat(doc.get(docMapper.mappers().getMapper("file2.author").names().indexName()), nullValue());
|
||||
assertThat(doc.get(docMapper.mappers().getMapper("file2.keywords").names().indexName()), nullValue());
|
||||
assertThat(doc.get(docMapper.mappers().getMapper("file2.content_type").names().indexName()), nullValue());
|
||||
assertThat(doc.getField(docMapper.mappers().getMapper("file2.content_length").names().indexName()), nullValue());
|
||||
assertThat(doc.get(docMapper.mappers().getMapper("file2").fieldType().names().indexName()), nullValue());
|
||||
assertThat(doc.get(docMapper.mappers().getMapper("file2.title").fieldType().names().indexName()), nullValue());
|
||||
assertThat(doc.get(docMapper.mappers().getMapper("file2.author").fieldType().names().indexName()), nullValue());
|
||||
assertThat(doc.get(docMapper.mappers().getMapper("file2.keywords").fieldType().names().indexName()), nullValue());
|
||||
assertThat(doc.get(docMapper.mappers().getMapper("file2.content_type").fieldType().names().indexName()), nullValue());
|
||||
assertThat(doc.getField(docMapper.mappers().getMapper("file2.content_length").fieldType().names().indexName()), nullValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -92,19 +92,19 @@ public class EncryptedDocMapperTest extends AttachmentUnitTestCase {
|
|||
.endObject().bytes();
|
||||
|
||||
ParseContext.Document doc = docMapper.parse("person", "1", json).rootDoc();
|
||||
assertThat(doc.get(docMapper.mappers().getMapper("file1").names().indexName()), nullValue());
|
||||
assertThat(doc.get(docMapper.mappers().getMapper("file1.title").names().indexName()), nullValue());
|
||||
assertThat(doc.get(docMapper.mappers().getMapper("file1.author").names().indexName()), nullValue());
|
||||
assertThat(doc.get(docMapper.mappers().getMapper("file1.keywords").names().indexName()), nullValue());
|
||||
assertThat(doc.get(docMapper.mappers().getMapper("file1.content_type").names().indexName()), nullValue());
|
||||
assertThat(doc.getField(docMapper.mappers().getMapper("file1.content_length").names().indexName()), nullValue());
|
||||
assertThat(doc.get(docMapper.mappers().getMapper("file1").fieldType().names().indexName()), nullValue());
|
||||
assertThat(doc.get(docMapper.mappers().getMapper("file1.title").fieldType().names().indexName()), nullValue());
|
||||
assertThat(doc.get(docMapper.mappers().getMapper("file1.author").fieldType().names().indexName()), nullValue());
|
||||
assertThat(doc.get(docMapper.mappers().getMapper("file1.keywords").fieldType().names().indexName()), nullValue());
|
||||
assertThat(doc.get(docMapper.mappers().getMapper("file1.content_type").fieldType().names().indexName()), nullValue());
|
||||
assertThat(doc.getField(docMapper.mappers().getMapper("file1.content_length").fieldType().names().indexName()), nullValue());
|
||||
|
||||
assertThat(doc.get(docMapper.mappers().getMapper("file2.content").names().indexName()), containsString("World"));
|
||||
assertThat(doc.get(docMapper.mappers().getMapper("file2.title").names().indexName()), equalTo("Hello"));
|
||||
assertThat(doc.get(docMapper.mappers().getMapper("file2.author").names().indexName()), equalTo("kimchy"));
|
||||
assertThat(doc.get(docMapper.mappers().getMapper("file2.keywords").names().indexName()), equalTo("elasticsearch,cool,bonsai"));
|
||||
assertThat(doc.get(docMapper.mappers().getMapper("file2.content_type").names().indexName()), equalTo("text/html; charset=ISO-8859-1"));
|
||||
assertThat(doc.getField(docMapper.mappers().getMapper("file2.content_length").names().indexName()).numericValue().longValue(), is(344L));
|
||||
assertThat(doc.get(docMapper.mappers().getMapper("file2.content").fieldType().names().indexName()), containsString("World"));
|
||||
assertThat(doc.get(docMapper.mappers().getMapper("file2.title").fieldType().names().indexName()), equalTo("Hello"));
|
||||
assertThat(doc.get(docMapper.mappers().getMapper("file2.author").fieldType().names().indexName()), equalTo("kimchy"));
|
||||
assertThat(doc.get(docMapper.mappers().getMapper("file2.keywords").fieldType().names().indexName()), equalTo("elasticsearch,cool,bonsai"));
|
||||
assertThat(doc.get(docMapper.mappers().getMapper("file2.content_type").fieldType().names().indexName()), equalTo("text/html; charset=ISO-8859-1"));
|
||||
assertThat(doc.getField(docMapper.mappers().getMapper("file2.content_length").fieldType().names().indexName()).numericValue().longValue(), is(344L));
|
||||
}
|
||||
|
||||
@Test(expected = MapperParsingException.class)
|
||||
|
@ -128,19 +128,19 @@ public class EncryptedDocMapperTest extends AttachmentUnitTestCase {
|
|||
.endObject().bytes();
|
||||
|
||||
ParseContext.Document doc = docMapper.parse("person", "1", json).rootDoc();
|
||||
assertThat(doc.get(docMapper.mappers().getMapper("file1").names().indexName()), nullValue());
|
||||
assertThat(doc.get(docMapper.mappers().getMapper("file1.title").names().indexName()), nullValue());
|
||||
assertThat(doc.get(docMapper.mappers().getMapper("file1.author").names().indexName()), nullValue());
|
||||
assertThat(doc.get(docMapper.mappers().getMapper("file1.keywords").names().indexName()), nullValue());
|
||||
assertThat(doc.get(docMapper.mappers().getMapper("file1.content_type").names().indexName()), nullValue());
|
||||
assertThat(doc.getField(docMapper.mappers().getMapper("file1.content_length").names().indexName()), nullValue());
|
||||
assertThat(doc.get(docMapper.mappers().getMapper("file1").fieldType().names().indexName()), nullValue());
|
||||
assertThat(doc.get(docMapper.mappers().getMapper("file1.title").fieldType().names().indexName()), nullValue());
|
||||
assertThat(doc.get(docMapper.mappers().getMapper("file1.author").fieldType().names().indexName()), nullValue());
|
||||
assertThat(doc.get(docMapper.mappers().getMapper("file1.keywords").fieldType().names().indexName()), nullValue());
|
||||
assertThat(doc.get(docMapper.mappers().getMapper("file1.content_type").fieldType().names().indexName()), nullValue());
|
||||
assertThat(doc.getField(docMapper.mappers().getMapper("file1.content_length").fieldType().names().indexName()), nullValue());
|
||||
|
||||
assertThat(doc.get(docMapper.mappers().getMapper("file2").names().indexName()), containsString("World"));
|
||||
assertThat(doc.get(docMapper.mappers().getMapper("file2.title").names().indexName()), equalTo("Hello"));
|
||||
assertThat(doc.get(docMapper.mappers().getMapper("file2.author").names().indexName()), equalTo("kimchy"));
|
||||
assertThat(doc.get(docMapper.mappers().getMapper("file2.keywords").names().indexName()), equalTo("elasticsearch,cool,bonsai"));
|
||||
assertThat(doc.get(docMapper.mappers().getMapper("file2.content_type").names().indexName()), equalTo("text/html; charset=ISO-8859-1"));
|
||||
assertThat(doc.getField(docMapper.mappers().getMapper("file2.content_length").names().indexName()).numericValue().longValue(), is(344L));
|
||||
assertThat(doc.get(docMapper.mappers().getMapper("file2").fieldType().names().indexName()), containsString("World"));
|
||||
assertThat(doc.get(docMapper.mappers().getMapper("file2.title").fieldType().names().indexName()), equalTo("Hello"));
|
||||
assertThat(doc.get(docMapper.mappers().getMapper("file2.author").fieldType().names().indexName()), equalTo("kimchy"));
|
||||
assertThat(doc.get(docMapper.mappers().getMapper("file2.keywords").fieldType().names().indexName()), equalTo("elasticsearch,cool,bonsai"));
|
||||
assertThat(doc.get(docMapper.mappers().getMapper("file2.content_type").fieldType().names().indexName()), equalTo("text/html; charset=ISO-8859-1"));
|
||||
assertThat(doc.getField(docMapper.mappers().getMapper("file2.content_length").fieldType().names().indexName()).numericValue().longValue(), is(344L));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -81,7 +81,7 @@ public class LanguageDetectionAttachmentMapperTests extends AttachmentUnitTestCa
|
|||
ParseContext.Document doc = docMapper.parse("person", "1", xcb.bytes()).rootDoc();
|
||||
|
||||
// Our mapping should be kept as a String
|
||||
assertThat(doc.get(docMapper.mappers().getMapper("file.language").names().indexName()), equalTo(expected));
|
||||
assertThat(doc.get(docMapper.mappers().getMapper("file.language").fieldType().names().indexName()), equalTo(expected));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -133,6 +133,6 @@ public class LanguageDetectionAttachmentMapperTests extends AttachmentUnitTestCa
|
|||
ParseContext.Document doc = docMapper.parse("person", "1", xcb.bytes()).rootDoc();
|
||||
|
||||
// Our mapping should be kept as a String
|
||||
assertThat(doc.get(docMapper.mappers().getMapper("file.language").names().indexName()), equalTo("en"));
|
||||
assertThat(doc.get(docMapper.mappers().getMapper("file.language").fieldType().names().indexName()), equalTo("en"));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -64,18 +64,18 @@ public class MetadataMapperTest extends AttachmentUnitTestCase {
|
|||
.endObject().bytes();
|
||||
|
||||
ParseContext.Document doc = docMapper.parse("person", "1", json).rootDoc();
|
||||
assertThat(doc.get(docMapper.mappers().getMapper("file.content").names().indexName()), containsString("World"));
|
||||
assertThat(doc.get(docMapper.mappers().getMapper("file.name").names().indexName()), equalTo(filename));
|
||||
assertThat(doc.get(docMapper.mappers().getMapper("file.content").fieldType().names().indexName()), containsString("World"));
|
||||
assertThat(doc.get(docMapper.mappers().getMapper("file.name").fieldType().names().indexName()), equalTo(filename));
|
||||
if (expectedDate == null) {
|
||||
assertThat(doc.getField(docMapper.mappers().getMapper("file.date").names().indexName()), nullValue());
|
||||
assertThat(doc.getField(docMapper.mappers().getMapper("file.date").fieldType().names().indexName()), nullValue());
|
||||
} else {
|
||||
assertThat(doc.getField(docMapper.mappers().getMapper("file.date").names().indexName()).numericValue().longValue(), is(expectedDate));
|
||||
assertThat(doc.getField(docMapper.mappers().getMapper("file.date").fieldType().names().indexName()).numericValue().longValue(), is(expectedDate));
|
||||
}
|
||||
assertThat(doc.get(docMapper.mappers().getMapper("file.title").names().indexName()), equalTo("Hello"));
|
||||
assertThat(doc.get(docMapper.mappers().getMapper("file.author").names().indexName()), equalTo("kimchy"));
|
||||
assertThat(doc.get(docMapper.mappers().getMapper("file.keywords").names().indexName()), equalTo("elasticsearch,cool,bonsai"));
|
||||
assertThat(doc.get(docMapper.mappers().getMapper("file.content_type").names().indexName()), equalTo("text/html; charset=ISO-8859-1"));
|
||||
assertThat(doc.getField(docMapper.mappers().getMapper("file.content_length").names().indexName()).numericValue().longValue(), is(expectedLength));
|
||||
assertThat(doc.get(docMapper.mappers().getMapper("file.title").fieldType().names().indexName()), equalTo("Hello"));
|
||||
assertThat(doc.get(docMapper.mappers().getMapper("file.author").fieldType().names().indexName()), equalTo("kimchy"));
|
||||
assertThat(doc.get(docMapper.mappers().getMapper("file.keywords").fieldType().names().indexName()), equalTo("elasticsearch,cool,bonsai"));
|
||||
assertThat(doc.get(docMapper.mappers().getMapper("file.content_type").fieldType().names().indexName()), equalTo("text/html; charset=ISO-8859-1"));
|
||||
assertThat(doc.getField(docMapper.mappers().getMapper("file.content_length").fieldType().names().indexName()).numericValue().longValue(), is(expectedLength));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -53,9 +53,9 @@ public class SimpleAttachmentMapperTests extends AttachmentUnitTestCase {
|
|||
|
||||
ParseContext.Document doc = docMapper.parse("person", "1", json).rootDoc();
|
||||
|
||||
assertThat(doc.get(docMapper.mappers().getMapper("file.content_type").names().indexName()), startsWith("application/xhtml+xml"));
|
||||
assertThat(doc.get(docMapper.mappers().getMapper("file.title").names().indexName()), equalTo("XHTML test document"));
|
||||
assertThat(doc.get(docMapper.mappers().getMapper("file.content").names().indexName()), containsString("This document tests the ability of Apache Tika to extract content"));
|
||||
assertThat(doc.get(docMapper.mappers().getMapper("file.content_type").fieldType().names().indexName()), startsWith("application/xhtml+xml"));
|
||||
assertThat(doc.get(docMapper.mappers().getMapper("file.title").fieldType().names().indexName()), equalTo("XHTML test document"));
|
||||
assertThat(doc.get(docMapper.mappers().getMapper("file.content").fieldType().names().indexName()), containsString("This document tests the ability of Apache Tika to extract content"));
|
||||
|
||||
// re-parse it
|
||||
String builtMapping = docMapper.mappingSource().string();
|
||||
|
@ -65,9 +65,9 @@ public class SimpleAttachmentMapperTests extends AttachmentUnitTestCase {
|
|||
|
||||
doc = docMapper.parse("person", "1", json).rootDoc();
|
||||
|
||||
assertThat(doc.get(docMapper.mappers().getMapper("file.content_type").names().indexName()), startsWith("application/xhtml+xml"));
|
||||
assertThat(doc.get(docMapper.mappers().getMapper("file.title").names().indexName()), equalTo("XHTML test document"));
|
||||
assertThat(doc.get(docMapper.mappers().getMapper("file.content").names().indexName()), containsString("This document tests the ability of Apache Tika to extract content"));
|
||||
assertThat(doc.get(docMapper.mappers().getMapper("file.content_type").fieldType().names().indexName()), startsWith("application/xhtml+xml"));
|
||||
assertThat(doc.get(docMapper.mappers().getMapper("file.title").fieldType().names().indexName()), equalTo("XHTML test document"));
|
||||
assertThat(doc.get(docMapper.mappers().getMapper("file.content").fieldType().names().indexName()), containsString("This document tests the ability of Apache Tika to extract content"));
|
||||
}
|
||||
|
||||
public void testContentBackcompat() throws Exception {
|
||||
|
|
|
@ -141,8 +141,8 @@ public class VariousDocTest extends AttachmentUnitTestCase {
|
|||
|
||||
ParseContext.Document doc = docMapper.parse("person", "1", json).rootDoc();
|
||||
if (!errorExpected) {
|
||||
assertThat(doc.get(docMapper.mappers().getMapper("file.content").names().indexName()), not(isEmptyOrNullString()));
|
||||
logger.debug("-> extracted content: {}", doc.get(docMapper.mappers().getMapper("file").names().indexName()));
|
||||
assertThat(doc.get(docMapper.mappers().getMapper("file.content").fieldType().names().indexName()), not(isEmptyOrNullString()));
|
||||
logger.debug("-> extracted content: {}", doc.get(docMapper.mappers().getMapper("file").fieldType().names().indexName()));
|
||||
logger.debug("-> extracted metadata:");
|
||||
printMetadataContent(doc, AUTHOR);
|
||||
printMetadataContent(doc, CONTENT_LENGTH);
|
||||
|
@ -156,6 +156,6 @@ public class VariousDocTest extends AttachmentUnitTestCase {
|
|||
}
|
||||
|
||||
private void printMetadataContent(ParseContext.Document doc, String field) {
|
||||
logger.debug("- [{}]: [{}]", field, doc.get(docMapper.mappers().getMapper("file." + field).names().indexName()));
|
||||
logger.debug("- [{}]: [{}]", field, doc.get(docMapper.mappers().getMapper("file." + field).fieldType().names().indexName()));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue