Hi,
I have the case that I want to exclude a field from indexing (index=false). My object is not really complicated:
class Text(Document):
value = Text()
tokens = Nested(Token) # Token is an InnerDoc
class Index:
name = 'documents'
Somehow I have to tell the mapping mechanism that the tokens should not be indexed. I tried to use an Inner Meta class and the mapping attribute to specify this, but without success. I'm pretty sure that this is a minor issue and should be solvable pretty easy. Unfortunately, the documentation is not expressive enough at this point, maybe someone can help out with this.
You want to use Object instead and just pass in enabled=False in the constructor:
class Text(Document):
value = Text()
tokens = Object(Token, enabled=False, multi=True) # Token is an InnerDoc
class Index:
name = 'documents'
That way the field will be completely ignored by elasticsearch. You don't need to use nested because that only dictates how the index will be created, which we are not doing.
Hope this helps!
Most helpful comment
You want to use
Objectinstead and just pass inenabled=Falsein the constructor:That way the field will be completely ignored by elasticsearch. You don't need to use
nestedbecause that only dictates how the index will be created, which we are not doing.Hope this helps!