MultiValueIsoText

MultiValueIsoText (com.hawkore.ignite.lucene.MultiValueIsoText) is an extension class for QueryEntities to store multiple lucene-analyzed texts, like translations and alternate names of same QueryEntity's property.

MultiValueIsoText is composed by known iso languages (specific language AnalyzedText implementations) that can be lexically analyzed and a generic meta map to store any text under unknown iso code that uses StandardAnalyzedText implementation to analyze texts.

    (other known AnalyzedText...)

    /**
     * Known English AnalyzedText iso=en
     */
    @QueryTextField(hidden = true)
    EnglishAnalyzedText en;

    /**
     * Known Spanish AnalyzedText iso=es
     */
    @QueryTextField(hidden = true)
    SpanishAnalyzedText es;

    /**
     * Standard analyzed iso text Map (iso, StandardAnalizedText)
     * <p>
     * As not all languages are supported to be lexically analyzed, in
     * order to add support to any text, use this field to store this
     * "unsupported" languages as any other alternate name that will be analyzed
     * with an standard analyzer.
     * 
     */
    @QueryTextField(hidden = true, 
    stringMappers = {
            @QueryTextField.StringMapper(name = "meta._key", case_sensitive = true),
            @QueryTextField.StringMapper(name = "meta.value", column = "meta.text", case_sensitive = false)
    }, textMappers = {
            @QueryTextField.TextMapper(name = "meta.text", analyzer = "standard")
    }, booleanMappers = {
            @QueryTextField.BooleanMapper(name = "meta.machine")
    })
    protected HashMap<String, StandardAnalyzedText> meta;

AnalyzedText

property

type

Description

iso

String

An iso code/meta key (case sensitive).

text

String

A text value to index.

isMachine

boolean

An optional flag to tell whether text was auto-generated by a machine (language translations).

    (...)

    @QueryTextField(hidden = true, booleanMappers = { @QueryTextField.BooleanMapper })
    protected boolean machine;

    @QueryTextField(hidden = true, textMappers = {
            @QueryTextField.TextMapper(analyzer = "the language")
    })
    private String text;


    private String iso;

MultiValueIsoText's properties

  • property column represents all MultiValueIsoText's class fields.

  • iso column represents a known language's iso code corresponding to property.

  • language corresponding to iso code.

  • type of the property.

property

iso

language

type

ar

ar

arabic

com.hawkore.ignite.lucene.text.ArabicAnalyzedText

bg

bg

bulgarian

com.hawkore.ignite.lucene.text.BulgarianAnalyzedText

ca

ca

catalan

com.hawkore.ignite.lucene.text.CatalanAnalyzedText

cs

cs

czech

com.hawkore.ignite.lucene.text.CzechAnalyzedText

da

da

danish

com.hawkore.ignite.lucene.text.DanishAnalyzedText

de

de

german

com.hawkore.ignite.lucene.text.GermanAnalyzedText

el

el

greek

com.hawkore.ignite.lucene.text.GreekAnalyzedText

en

en

english

com.hawkore.ignite.lucene.text.EnglishAnalyzedText

es

es

spanish

com.hawkore.ignite.lucene.text.SpanishAnalyzedText

eu

eu

basque

com.hawkore.ignite.lucene.text.BasqueAnalyzedText

fa

fa

persian

com.hawkore.ignite.lucene.text.PersianAnalyzedText

fi

fi

finnish

com.hawkore.ignite.lucene.text.FinnishAnalyzedText

fr

fr

french

com.hawkore.ignite.lucene.text.FrenchAnalyzedText

ga

ga

irish

com.hawkore.ignite.lucene.text.IrishAnalyzedText

gl

gl

galician

com.hawkore.ignite.lucene.text.GalicianAnalyzedText

hi

hi

hindi

com.hawkore.ignite.lucene.text.HindiAnalyzedText

hu

hu

hungarian

com.hawkore.ignite.lucene.text.HungarianAnalyzedText

hy

hy

armenian

com.hawkore.ignite.lucene.text.ArmenianAnalyzedText

id

id

indonesian

com.hawkore.ignite.lucene.text.IndonesianAnalyzedText

it

it

italian

com.hawkore.ignite.lucene.text.ItalianAnalyzedText

ja

ja

japanese

com.hawkore.ignite.lucene.text.JapaneseAnalyzedText

ku

ku

sorani

com.hawkore.ignite.lucene.text.SoraniAnalyzedText

lt

lt

lithuanian

com.hawkore.ignite.lucene.text.LithuanianAnalyzedText

lv

lv

latvian

com.hawkore.ignite.lucene.text.LatvianAnalyzedText

nl

nl

dutch

com.hawkore.ignite.lucene.text.DutchAnalyzedText

no

no

norwegian

com.hawkore.ignite.lucene.text.NorwegianAnalyzedText

pt

pt

portuguese

com.hawkore.ignite.lucene.text.PortugueseAnalyzedText

ro

ro

romanian

com.hawkore.ignite.lucene.text.RomanianAnalyzedText

ru

ru

russian

com.hawkore.ignite.lucene.text.RussianAnalyzedText

sv

sv

swedish

com.hawkore.ignite.lucene.text.SwedishAnalyzedText

th

th

thai

com.hawkore.ignite.lucene.text.ThaiAnalyzedText

tr

tr

turkish

com.hawkore.ignite.lucene.text.TurkishAnalyzedText

zh

zh

chinese

com.hawkore.ignite.lucene.text.ChineseAnalyzedText

meta



java.util.HashMap<String, com.hawkore.ignite.lucene.text.StandardAnalyzedText>

Example: See MultiValueIsoText functions for H2

@QueryTextField(
    // Index will be refreshed every 60 seconds, with lucene index optimization every
    // 10 minutes
    indexOptions = @IndexOptions(refreshSeconds = 60, partitions = 10, optimizerSchedule = "*/10 * * * *"),

    // this will create a field named "id" into Lucene Document that will be
    // indexed; mapped to composed primary key PoiKey's @QuerySqlField "id"
    integerMappers = @IntegerMapper(name = "id"),

    // this will create a field named "countryCode" into Lucene Document that
    // will be indexed; mapped to composed primary PoiKey's @QuerySqlField
    // "countryCode"
    stringMappers = @StringMapper(name = "countryCode"))
public class Poi {

    private PoiKey key;

    @QueryTextField
    @QuerySqlField
    private MultiValueIsoText name;


    @QueryTextField
    @QuerySqlField
    private MultiValueIsoText description;

    /**
     * WGS84 coordinates lat/lon - EPSG:4326 - SRID
     * <p>
     * Added double index for testing purposes:
     * <ul>
     * <li>Grid H2 geospatial index
     * <li>
     * <li>Lucene indexed field with geoShapeMapper
     * <li>
     * </ul>
     */
    @QuerySqlField(index = true)
    @QueryTextField(geoShapeMappers = {
            @GeoShapeMapper(transformations = @GeoTransformation(type = GeoTransformationType.CENTROID))
    })
    private Geometry place;

    @QuerySqlField(index = true)
    private String type;

    (...)
}    
public class PoiKey {

    // index=true will create a Grid H2 index (POIKEY_ID_IDX index name) for
    // non lucene searches
    @QuerySqlField(index = true)
    private Integer id;

    // affinity key annotated is auto-indexed on a Grid H2 index (AFFINITY_KEY
    // index name) for non lucene searches annotated it with @QuerySqlField to publish as table column to allow use
    // it from a lucene index mapper
    @QuerySqlField
    @AffinityKeyMapped
    private String countryCode;

    (...)
}
select 
id,
countryCode,
-- get name's es translation, if not found get en translation
public.hkmv_text(name, 'es', 'en') as name, 
-- get description's es translation, if not found get en translation
public.hkmv_text(description, 'es', 'en') as description,
type,
-- get name's iata alternate name, if not found return null
public.hkmv_text(name, 'iata', null) as iata
FROM "pois".poi 
limit 10;