Search in wrong Index

Hi all, I'm new to Elasticsearch, I had to add a couple of field in mssql, the same fields must be created in elasticsearch.
To add new fields I follow this procedure:

1 Copy the index mapping from the original index
GET sgs_products/_mapping

2 Create the new destination index and add the new fields as needed
PUT sgs_products_dest
{
"mappings": {
"properties": {
"availableTranslations": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"barCode": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"brandId": {
"type": "long"
},
"brandProductNameId": {
"type": "long"
},

  Ecc…

3 Do the reindex from the original index to the new index
POST _reindex
{
"source":{
"index":"sgs_products"
},
"dest":{
"index":"sgs_products_dest"
}
}

4 Valorize the new added fields with a default value to all documents
POST sgs_products_dest/_update_by_query
{
"script": {
"source": "ctx._source.isNewentry = true",
"lang": "painless"
}
}
POST sgs_products_dest/_update_by_query
{
"script": {
"source": "ctx._source.isExclusive = false",
"lang": "painless"
}
}
POST sgs_products_dest/_update_by_query
{
"script": {
"source": "ctx._source.isNewEntryFrom = "1999-01-01"",
"lang": "painless"
}
}
POST sgs_products_dest/_update_by_query
{
"script": {
"source": "ctx._source.isNewEntryTo = "1999-01-01"",
"lang": "painless"
}
}
POST sgs_products_dest/_update_by_query
{
"script": {
"source": "ctx._source.isSpecialOfferFrom = "1999-01-01"",
"lang": "painless"
}
}
POST sgs_products_dest/_update_by_query
{
"script": {
"source": "ctx._source.isSpecialOfferTo = "1999-01-01"",
"lang": "painless"
}
}

5 Delete the old index
DELETE sgs_products

6 Get the mapping from the new index
GET sgs_products_dest/_mapping

7 Re-create the original index with the mapping obtained at step 6
PUT sgs_products
{
"mappings": {
"properties": {
"availableTranslations": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"barCode": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"brandId": {
"type": "long"
},
"brandProductNameId": {
"type": "long"
},
Ecc…

8 Do inverse reindex from new index to the original index to have the original index with original name.
POST _reindex
{
"source":{
"index":"sgs_products_dest"
},
"dest":{
"index":"sgs_products"
}
}

Now when I query elastic search by using Nest library the field isNewentry is always false.

Could some one help me to understand why the isNewentry is false ?

Thank you very much
Gio

Welcome to our community! :smiley:
Please format your code/logs/config using the </> button, or markdown style back ticks. It helps to make things easy to read which helps us help you :slight_smile:

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.