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 |
arabic |
|
|
bg |
bulgarian |
|
|
ca |
catalan |
|
|
cs |
czech |
|
|
da |
danish |
|
|
de |
german |
|
|
el |
greek |
|
|
en |
english |
|
|
es |
spanish |
|
|
eu |
basque |
|
|
fa |
persian |
|
|
fi |
finnish |
|
|
fr |
french |
|
|
ga |
irish |
|
|
gl |
galician |
|
|
hi |
hindi |
|
|
hu |
hungarian |
|
|
hy |
armenian |
|
|
id |
indonesian |
|
|
it |
italian |
|
|
ja |
japanese |
|
|
ku |
sorani |
|
|
lt |
lithuanian |
|
|
lv |
latvian |
|
|
nl |
dutch |
|
|
no |
norwegian |
|
|
pt |
portuguese |
|
|
ro |
romanian |
|
|
ru |
russian |
|
|
sv |
swedish |
|
|
th |
thai |
|
|
tr |
turkish |
|
|
zh |
chinese |
|
|
|
|
|
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;