Uploaded image for project: 'Documentation'
  1. Documentation
  2. DOCS-3412

Explain how to drop a Full Text index

    XMLWordPrintableJSON

Details

    • Icon: Improvement Improvement
    • Resolution: Done
    • Icon: Critical - P2 Critical - P2
    • v1.3.5
    • mongodb-2.6, mongodb-3.0
    • manual

    Description

      TL;TR:
      We need to clarify how to delete Full Text indexes, and user must use the proper key:
      db.collection.dropIndex(

      { "_fts" : "text", "_ftsx" : 1 }

      )

      Details

      The db.collection.dropIndex(<idx>) use the key of the index as parameter. For most of the index the "key" is the value you pass when you create the index.

      This is not the case for a Full Text index.

      Let's take an example:

      — standard index -----
      db.collection.ensureIndex(

      {name : 1}

      );

      user can simply do:
      db.collection.dropIndex(

      {name : 1}

      );
      >> OK

      – full text search index –
      db.collection.ensureIndex(

      { description : "text"}

      );

      if the user execute :
      db.collection.dropIndex(

      { description : "text"}

      );
      the following error is raised:
      "can't find index with key:

      { description: \"text\" }

      "

      This is because the key is not

      { description : "text"}

      as you can look using the command:
      db.collection.getIndexes( );

      The key of the index is:

      { "_fts" : "text", "_ftsx" : 1 }

      The proper command is:
      db.collection.dropIndex(

      { "_fts" : "text", "_ftsx" : 1 }

      )

      Attachments

        Activity

          People

            kay.kim@mongodb.com Kay Kim (Inactive)
            tugdual.grall Tugdual Grall
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              9 years, 38 weeks, 6 days ago