org.apache.lucene.codecs.perfield.PerFieldPostingsFormat Java Examples

The following examples show how to use org.apache.lucene.codecs.perfield.PerFieldPostingsFormat. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MtasCodec.java    From mtas with Apache License 2.0 6 votes vote down vote up
@Override
public PostingsFormat postingsFormat() {
  initDelegate();
  if (delegate.postingsFormat() instanceof PerFieldPostingsFormat) {
    Codec defaultCodec = Codec.getDefault();
    PostingsFormat defaultPostingsFormat = defaultCodec.postingsFormat();
    if (defaultPostingsFormat instanceof PerFieldPostingsFormat) {
      defaultPostingsFormat = ((PerFieldPostingsFormat) defaultPostingsFormat)
          .getPostingsFormatForField(null);
      if ((defaultPostingsFormat == null)
          || (defaultPostingsFormat instanceof PerFieldPostingsFormat)) {
        // fallback option
        return new MtasCodecPostingsFormat(
            PostingsFormat.forName("Lucene70"));
      } else {
        return new MtasCodecPostingsFormat(defaultPostingsFormat);
      }
    } else {
      return new MtasCodecPostingsFormat(defaultPostingsFormat);
    }
  } else {
    return new MtasCodecPostingsFormat(delegate.postingsFormat());
  }
}
 
Example #2
Source File: TestUtil.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
public static String getPostingsFormat(Codec codec, String field) {
  PostingsFormat p = codec.postingsFormat();
  if (p instanceof PerFieldPostingsFormat) {
    return ((PerFieldPostingsFormat)p).getPostingsFormatForField(field).getName();
  } else {
    return p.getName();
  }
}
 
Example #3
Source File: TestCodecSupport.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
public void testPostingsFormats() {
  Codec codec = h.getCore().getCodec();
  Map<String, SchemaField> fields = h.getCore().getLatestSchema().getFields();
  SchemaField schemaField = fields.get("string_direct_f");
  PerFieldPostingsFormat format = (PerFieldPostingsFormat) codec.postingsFormat();
  assertEquals("Direct", format.getPostingsFormatForField(schemaField.getName()).getName());
  schemaField = fields.get("string_standard_f");
  assertEquals(TestUtil.getDefaultPostingsFormat().getName(), format.getPostingsFormatForField(schemaField.getName()).getName());
  schemaField = fields.get("string_f");
  assertEquals(TestUtil.getDefaultPostingsFormat().getName(), format.getPostingsFormatForField(schemaField.getName()).getName());
}
 
Example #4
Source File: TestCodecSupport.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
public void testDynamicFieldsPostingsFormats() {
  Codec codec = h.getCore().getCodec();
  PerFieldPostingsFormat format = (PerFieldPostingsFormat) codec.postingsFormat();

  assertEquals("Direct", format.getPostingsFormatForField("foo_direct").getName());
  assertEquals("Direct", format.getPostingsFormatForField("bar_direct").getName());
  assertEquals(TestUtil.getDefaultPostingsFormat().getName(), format.getPostingsFormatForField("foo_standard").getName());
  assertEquals(TestUtil.getDefaultPostingsFormat().getName(), format.getPostingsFormatForField("bar_standard").getName());
}