Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document Mapping Failing #42

Closed
mattporritt opened this issue Apr 15, 2019 · 3 comments
Closed

Document Mapping Failing #42

mattporritt opened this issue Apr 15, 2019 · 3 comments
Assignees

Comments

@mattporritt
Copy link
Contributor

Currently there is an issue when the document mapping is created for the index. This is causing all document field types to be set to "text" instead of integer, date etc. This is causing date sorting to not work for search results. It is also causing strange result behaviour.

Also to make it worse, this condition happens on a real site, but does not happen for unit tests. The unit tests get the document created correctly.

Real site document mapping

curl -XGET 'http://localhost:9200/moodle2/_mapping?pretty=true' 
{
  "moodle2" : {
    "mappings" : {
      "doc" : {
        "properties" : {
          "areaid" : {
            "type" : "text",
            "fields" : {
              "keyword" : {
                "type" : "keyword",
                "ignore_above" : 256
              }
            }
          },
          "content" : {
            "type" : "text",
            "fields" : {
              "keyword" : {
                "type" : "keyword",
                "ignore_above" : 256
              }
            }
          },
          "contextid" : {
            "type" : "text",
            "fields" : {
              "keyword" : {
                "type" : "keyword",
                "ignore_above" : 256
              }
            }
          },
          "courseid" : {
            "type" : "text",
            "fields" : {
              "keyword" : {
                "type" : "keyword",
                "ignore_above" : 256
              }
            }
          },
          "description1" : {
            "type" : "text",
            "fields" : {
              "keyword" : {
                "type" : "keyword",
                "ignore_above" : 256
              }
            }
          },
          "id" : {
            "type" : "text",
            "fields" : {
              "keyword" : {
                "type" : "keyword",
                "ignore_above" : 256
              }
            }
          },
          "itemid" : {
            "type" : "long"
          },
          "modified" : {
            "type" : "text",
            "fields" : {
              "keyword" : {
                "type" : "keyword",
                "ignore_above" : 256
              }
            }
          },
          "owneruserid" : {
            "type" : "text",
            "fields" : {
              "keyword" : {
                "type" : "keyword",
                "ignore_above" : 256
              }
            }
          },
          "parentid" : {
            "type" : "text",
            "fields" : {
              "keyword" : {
                "type" : "keyword",
                "ignore_above" : 256
              }
            }
          },
          "title" : {
            "type" : "text",
            "fields" : {
              "keyword" : {
                "type" : "keyword",
                "ignore_above" : 256
              }
            }
          },
          "type" : {
            "type" : "long"
          },
          "userid" : {
            "type" : "long"
          }
        }
      }
    }
  }
}

Unit test document mapping

curl -XGET 'http://localhost:9200/moodle_test/_mapping?pretty=true' 
{
  "moodle_test" : {
    "mappings" : {
      "doc" : {
        "properties" : {
          "areaid" : {
            "type" : "keyword"
          },
          "content" : {
            "type" : "text"
          },
          "contextid" : {
            "type" : "integer"
          },
          "courseid" : {
            "type" : "integer"
          },
          "id" : {
            "type" : "keyword"
          },
          "itemid" : {
            "type" : "integer"
          },
          "modified" : {
            "type" : "date",
            "format" : "epoch_second"
          },
          "owneruserid" : {
            "type" : "integer"
          },
          "parentid" : {
            "type" : "keyword"
          },
          "title" : {
            "type" : "text"
          },
          "type" : {
            "type" : "integer"
          }
        }
      }
    }
  }
}
@mattporritt
Copy link
Contributor Author

A current work around seems to be delete your index in Elasticsearch and reindex.
This can be done using the Moodle CLI search reindex command

1 similar comment
@mattporritt
Copy link
Contributor Author

A current work around seems to be delete your index in Elasticsearch and reindex.
This can be done using the Moodle CLI search reindex command

@mattporritt
Copy link
Contributor Author

The mechanism that causes this issue, is if indexing is run the first time without explicitly marking the index job as fullindex then the document mapping will be incorrectly created.
This will happen generally when the plugin is installed and we let the Moodle scheduled task run without first running the index job via the cli.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant