Nous avons dû recréer l'indexeur Registry_promotion_condition qui avait un analyseur personnalisé appelé custom_value_analyzer. Parce que l'analyseur ne se configure pas par indexeur, nous l'avons appliqué via un appel API.
POST /registry_promotion_condition/_close
PUT /registry_promotion_condition/_settings
{
"analysis" : {
"analyzer" : {
"condition_value_analyzer" : {
"type" : "custom",
"tokenizer" : "punctuation"
}
},
"tokenizer" : {
"punctuation" : {
"pattern" : ",",
"type" : "pattern"
}
}
}
}
POST /registry_promotion_condition/_open
Après avoir appliqué cet analyseur en dev et en staging, nous avons pu récupérer les données sans problème en utilisant l'appel api suivant.
POST /registry_promotion_condition/promotion_conditions/_search
{
"from": 0,
"size": 10,
"query": {
"bool": {
"must": [
{
"term": {
"promotionDisplayStatus": {
"value": true,
"boost": 1
}
}
},
{
"match_phrase": {
"conditionValue": {
"query": 4242560,
"analyzer": "condition_value_analyzer",
"slop": 0,
"zero_terms_query": "NONE",
"boost": 0.8
}
}
}
],
"adjust_pure_negative": true,
"boost": 1
}
},
"sort": [
{
"promotionId": {
"order": "asc"
}
}
]
}
mais en live ça ne donne pas de réponse vide. Avez-vous une idée de pourquoi? Existe-t-il une configuration pour autoriser un analyseur personnalisé
Ceci est ma cartographie en environnement réel
{
"registry_promotion_condition" : {
"mappings" : {
"promotion_conditions" : {
"properties" : {
"conditionDataType" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"conditionEntityFieldId" : {
"type" : "long"
},
"conditionId" : {
"type" : "long"
},
"conditionStatus" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"conditionValue" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"conditionVersion" : {
"type" : "long"
},
"createYear" : {
"type" : "long"
},
"promotionActiveFrom" : {
"type" : "date"
},
"promotionActiveUntil" : {
"type" : "date"
},
"promotionCode" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"promotionCreatedAt" : {
"type" : "date"
},
"promotionDescription" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"promotionDiscountAmount" : {
"type" : "float"
},
"promotionDiscountType" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"promotionDisplayName" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"promotionDisplayStatus" : {
"type" : "boolean"
},
"promotionId" : {
"type" : "long"
},
"promotionMaxDiscountAmount" : {
"type" : "float"
},
"promotionName" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"promotionRuleFile" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"promotionServiceType" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"promotionStatus" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"promotionType" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"promotionVersion" : {
"type" : "long"
},
"routingKey" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
}
}
}
}
}
}
1 réponse
Essayez de changer vos mappages de:
{
"registry_promotion_condition" : {
"mappings" : {
"promotion_conditions" : {
"properties" : {
"conditionDataType" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"conditionEntityFieldId" : {
"type" : "long"
},
"conditionId" : {
"type" : "long"
},
"conditionStatus" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"conditionValue" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"conditionVersion" : {
"type" : "long"
},
"createYear" : {
"type" : "long"
},
"promotionActiveFrom" : {
"type" : "date"
},
"promotionActiveUntil" : {
"type" : "date"
},
"promotionCode" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"promotionCreatedAt" : {
"type" : "date"
},
"promotionDescription" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"promotionDiscountAmount" : {
"type" : "float"
},
"promotionDiscountType" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"promotionDisplayName" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"promotionDisplayStatus" : {
"type" : "boolean"
},
"promotionId" : {
"type" : "long"
},
"promotionMaxDiscountAmount" : {
"type" : "float"
},
"promotionName" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"promotionRuleFile" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"promotionServiceType" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"promotionStatus" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"promotionType" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"promotionVersion" : {
"type" : "long"
},
"routingKey" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
}
}
}
}
}
}
À (analyseur ajouté à votre champ conditionValue ):
{
"registry_promotion_condition" : {
"mappings" : {
"promotion_conditions" : {
"properties" : {
"conditionDataType" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"conditionEntityFieldId" : {
"type" : "long"
},
"conditionId" : {
"type" : "long"
},
"conditionStatus" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"conditionValue" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
},
"analyzer":"condition_value_analyzer"
},
"conditionVersion" : {
"type" : "long"
},
"createYear" : {
"type" : "long"
},
"promotionActiveFrom" : {
"type" : "date"
},
"promotionActiveUntil" : {
"type" : "date"
},
"promotionCode" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"promotionCreatedAt" : {
"type" : "date"
},
"promotionDescription" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"promotionDiscountAmount" : {
"type" : "float"
},
"promotionDiscountType" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"promotionDisplayName" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"promotionDisplayStatus" : {
"type" : "boolean"
},
"promotionId" : {
"type" : "long"
},
"promotionMaxDiscountAmount" : {
"type" : "float"
},
"promotionName" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"promotionRuleFile" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"promotionServiceType" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"promotionStatus" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"promotionType" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"promotionVersion" : {
"type" : "long"
},
"routingKey" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
}
}
}
}
}
}
Vous devrez supprimer votre index afin de mettre à jour votre mappage et réindexer à nouveau. voir mon répondre à propos de la réindexation.
De nouvelles questions
elasticsearch
Elasticsearch est un moteur de recherche Open Source (Apache 2), distribué, RESTful, basé sur Lucene.