Elasticsearch_dsl doesn't parse results correctly while using Alias
See original GitHub issueHello guys,
In my Elastic deployement I have multiple Indexes (tables?). For a reason, I want to use the Alias on those Indexes.
When I’m targetting an Index with is original Title/name, the result is correctly parsed, which means every “hit” becomes a proper object. So I can do, Object.name or Object.to_json().
BUT, when I give an Alias to the same Index and then do the same query by using the Alias instead the origin name, the result it is not parsed correctly. All the hits still a Hit object.
Query example (very simple):
{
"bool":{
"must":[
{
"match":{
"store":"Id",
"active":True
}
}
}
]
}
- Elasticsearch-dsl Version: 7.1.0
- Deployment version: 7.8.0
My current model (document):
from elasticsearch_dsl import Document, Boolean, Text, Float, InnerDoc, Nested, Keyword
from utils.date_time_util import now, ESArrowDateTimeField
class Product(Document):
created = ESArrowDateTimeField(required=True)
modified = ESArrowDateTimeField(required=True)
active = Boolean(required=True)
deleted = Boolean(required=True)
store = Keyword(required=True)
title = Text(required=True)
description = Text()
link = Text()
external_id = Keyword()
# Pricing
price = Float()
sale_price = Float()
vat = Float()
currency = Text(required=True)
# Variant group
item_group_id = Text()
# From XML Standard SS2 - Google: https://support.google.com/merchants/answer/7052112
adult = Boolean()
age_group = Text()
brand = Text()
color = Text()
condition = Text()
gender = Keyword()
category = Text()
material = Text()
kind = Text(multi=True)
# Product identifiers - SKU
gtin = Text()
mpn = Text()
@property
def id(self):
return self.meta.id
def initialize_defaults(self):
if not self.created:
self.created = now()
self.modified = now()
if self.active is None:
self.active = True
if self.deleted is None:
self.deleted = False
if self.description is None:
self.description = ''
if self.link is None:
self.link = '/'
if self.vat is None:
self.vat = 0.0
if self.currency is None:
self.currency = 'NOK'
if self.additional_image_links is None:
self.additional_image_links = []
if self.kind is None:
self.kind = []
def reload(self):
product = Product.get(id=self.id)
self = product
return product
def to_json(self):
del self['created']
del self['modified']
res = self.to_dict()
res['id'] = self.id
res['_id'] = {
'$oid': self.id
}
return res
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (1 by maintainers)
Top Results From Across the Web
Query string query | Elasticsearch Guide [8.5] | Elastic
This query uses a syntax to parse and split the provided query string based on operators, such as AND or NOT . The...
Read more >Breaking changes in 7.0 | Elasticsearch Guide [7.17] | Elastic
An Elasticsearch 7.0 node will not start in the presence of indices ... in a geo_shape query is now processed correctly when specified...
Read more >Search your data | Elasticsearch Guide [8.5] | Elastic
A search query, or query, is a request for information about data in Elasticsearch data streams or indices. You can think of a...
Read more >Reindex API | Elasticsearch Guide [8.5] | Elastic
The source can be any existing index, alias, or data stream. The destination must differ from the source. For example, you cannot reindex...
Read more >Update By Query API | Elasticsearch Guide [8.5] | Elastic
If no query is specified, performs an update on every document in the data ... Any update requests that completed successfully still stick,...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi @GabrielBlondeau-Kirby Try to implement the
_matches
classmethod, like this (ref), it’s work for me !Hey @florianvazelle , it works !! awesome dude, thank you a lot 😉 !!