Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-9796

Non-text fields in compound text index spec are re-ordered by reIndex or initial sync

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 2.4.5, 2.5.1
    • Affects Version/s: 2.5.0
    • Component/s: Text Search
    • None
    • ALL

      Create the index:

      db.collection.ensureIndex({ words: "text", additional: 1 })
      db.collection.getIndexes()
      [
        {
          "v": 1,
          "key": {
            "_id": 1
          },
          "ns": "test.collection",
          "name": "_id_"
        },
        {
          "v": 1,
          "key": {
            "_fts": "text",
            "_ftsx": 1,
            "additional": 1
          },
          "ns": "test.collection",
          "name": "words_text_additional_1",
          "weights": {
            "words": 1
          },
          "default_language": "english",
          "language_override": "language",
          "textIndexVersion": 1
        }
      ]
      

      reIndex() reorders fields:

      db.collection.reIndex()
      [
        {
          "v": 1,
          "key": {
            "_id": 1
          },
          "ns": "test.collection",
          "name": "_id_"
        },
        {
          "v": 1,
          "key": {
            "additional": 1,
            "_fts": "text",
            "_ftsx": 1
          },
          "ns": "test.collection",
          "name": "words_text_additional_1",
          "weights": {
            "words": 1
          },
          "default_language": "english",
          "language_override": "language",
          "textIndexVersion": 1
        }
      ]
      

      At this point the index cannot be used as the additional field must appended and not a prefix.

            Assignee:
            rassi J Rassi
            Reporter:
            tyler@10gen.com Tyler Brock
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: