You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ponymail.apache.org by se...@apache.org on 2018/05/17 22:58:37 UTC

[incubator-ponymail] branch master updated: Bug: setup.py fails with ES2 - fielddata

This is an automated email from the ASF dual-hosted git repository.

sebb pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-ponymail.git


The following commit(s) were added to refs/heads/master by this push:
     new e274412  Bug: setup.py fails with ES2 - fielddata
e274412 is described below

commit e2744129a6ef4b56e9fb5debccc06fd96155bc62
Author: Sebb <se...@apache.org>
AuthorDate: Thu May 17 23:58:35 2018 +0100

    Bug: setup.py fails with ES2 - fielddata
    
    This fixes #453
---
 CHANGELOG.md   |  1 +
 tools/setup.py | 14 +++++++++++---
 2 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index fe2281d..bab7ec8 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,4 +1,5 @@
 ## Changes in 0.11-SNAPSHOT
+- Bug: setup.py fails with ES2 - fielddata (#453)
 - Bug: setup.py --default should not prompt for urlPrefix (#452)
 - Bug: copy-list.py does not work (#450)
 - Bug: unnecessary test (will always succeed) in copy-list.py (#451)
diff --git a/tools/setup.py b/tools/setup.py
index 4dffbe6..378608b 100755
--- a/tools/setup.py
+++ b/tools/setup.py
@@ -206,6 +206,10 @@ def createIndex():
         retry_on_timeout=True
         )
 
+    DB_VERSION=es.info()['version']['number']
+    DB_MAJOR=int(DB_VERSION.split('.')[0])
+    print("Versions: library %d (%s), engine %d (%s)" % (ES_MAJOR, '.'.join(map(str,ES_VERSION)) , DB_MAJOR, DB_VERSION))
+
     # Check if index already exists
     if es.indices.exists(dbname):
         if args.soe:
@@ -297,7 +301,7 @@ def createIndex():
             },
             "subject" : {
               "type" : "string",
-              "fielddata": True
+              "fielddata": True # dropped later if DB_MAJOR==2
             },
             "to" : {
               "type" : "string"
@@ -442,7 +446,7 @@ def createIndex():
             },
             "subject" : {
               "type" : "string",
-              "fielddata": True
+              "fielddata": True # dropped later if DB_MAJOR==2
 #               "index" : "not_analyzed"
             },
             "to" : {
@@ -456,7 +460,11 @@ def createIndex():
           }
         }
     }
- 
+
+    if DB_MAJOR == 2: # ES 2 handles fielddata differently
+        del mappings['mbox']['properties']['subject']['fielddata']
+        del mappings['notifications']['properties']['subject']['fielddata']
+
     res = es.indices.create(index = dbname, body = {
                 "mappings" : mappings,
                 "settings": settings

-- 
To stop receiving notification emails like this one, please contact
sebb@apache.org.