INNER CODE UNIT · JavaScript

hasTextIndex

furey/mongodb-lens · mongodb-lens.js:2649

            const hasTextIndex = indexes.some(idx => Object.values(idx.key).includes('text'))

            if (!hasTextIndex) {
              return {
                content: [{
                  type: 'text',
                  text: `No text index found on collection '${collection}'.\n\nText search requires a text index. Create one with:\n\ncreate-index {\n  "collection": "${collection}",\n  "keys": "{\\"fieldName\\": \\"text\\"}"\n}`
                }]
              }
            }
          } catch (indexError) {
            log(`Warning: Unable to check for text indexes: ${indexError.message}`, true)
          }

          const textQuery = { $search: searchText }
          if (language) textQuery.$language = language
          if (caseSensitive === 'true') textQuery.$caseSensitive = true
          if (diacriticSensitive === 'true') textQuery.$diacriticSensitive = true

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…