Skip to content

Commit

Permalink
add non analysed field
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas Brognoli committed Feb 15, 2019
1 parent 9de1721 commit 6978116
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions luqum/tests/test_es_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@
from luqum.elasticsearch import ElasticsearchQueryBuilder, SchemaAnalyzer
from luqum.parser import parser

client = Elasticsearch()
MAJOR_ES = elasticsearch_dsl.VERSION[0]
if MAJOR_ES > 2:
from elasticsearch_dsl import Keyword

co = connections.create_connection(hosts=["localhost"], timeout=20)
if elasticsearch_dsl.VERSION[0] == 6:
ES6 = False
if MAJOR_ES == 6:
from elasticsearch_dsl import Text, Document, InnerDoc

ES6 = True
else:
from elasticsearch_dsl import (
Expand All @@ -23,13 +24,14 @@
InnerObjectWrapper as InnerDoc,
)

ES6 = False

client = Elasticsearch()
co = connections.create_connection(hosts=["localhost"], timeout=20)

class Illustrator(InnerDoc):
name = Text()
birthdate = Date()
nationality = Text(index="not_analyzed")
if MAJOR_ES > 2:
class Illustrator(InnerDoc):
name = Text()
birthdate = Date()
nationality = Keyword()


class Book(Document):
Expand All @@ -50,7 +52,7 @@ class Index:
properties={
"name": Text(),
"birthdate": Date(),
"nationality": Text(index="not_analyzed"),
"nationality": Keyword() if MAJOR_ES > 2 else Text(index="not_analyzed")
}
)

Expand Down Expand Up @@ -86,7 +88,7 @@ def setUpClass(cls):
MESSAGES_SCHEMA = {"mappings": Book._doc_type.mapping.to_dict()}
schema_analizer = SchemaAnalyzer(MESSAGES_SCHEMA)
cls.es_builder = ElasticsearchQueryBuilder(
**schema_analizer.query_builder_options()
**schema_analizer.query_builder_options(),
)
add_data()

Expand Down

0 comments on commit 6978116

Please sign in to comment.