Atlas Search Index Build Fail

Hi Everyone,

I have a few thousand documents I’m trying to make an Atlas lucene search index for, on a specific field.

An extremely simplified version of my docs look like this…

{
    name:'XYZ',
    lastUpdated: date 1,
    fundamentalData:{
        description: stuff,
        latUpdatedFA: date 2,
    },
}

When i try to build a very simple search index on fundamentalData**.description,** I continuously get a failure to build message.

’ Your index could not be built: Unexpected error: DocValuesField “$type:date/lastUpdated” appears more than once in this document (only one value is allowed per field) ’

This indicates that the key/field ‘lastUpdated’ appears more than once in a given document, but I have confirmed via python that it in fact does not. (see code at the end)

I also know that fundamentalData.lastUpdatedFA is similar to lastUpdated, but this should not matter, as I have confirmed that as long as it’s not character for character, it’s not a problem.

Thoughts? When i create the search index the old fashioned way on a localhost copy of my database via …

db.collection.createIndex( { Description: "text" } )

… everything works perfectly fine. It’s my understanding that the Atlas Search algorithm behaves quite differently than the legacy createIndex, though.

Thanks,

Logan

`
def find_duplicate_lastUpdated(collection):
duplicate_lastUpdated_docs =
for doc in collection.find():
lastUpdated_count = str(doc).count(“‘lastUpdated’”)
if lastUpdated_count > 1:
duplicate_lastUpdated_docs.append(doc[‘name’])
time.sleep(0.01) # sleep for 10 milliseconds
return duplicate_lastUpdated_docs

collection = db[“assetdatas”]
duplicates = find_duplicate_lastUpdated(collection)
len(duplicates)
`

HI @Logan_McNulty

Can you share an actual sample document? I generated documents like this, and didn’t run into this error.

{
  "_id": {
    "$oid": "65eb4ec0ca553dd13bc9d935"
  },
  "name": "Ian Logan",
  "lastUpdated": {
    "$date": "2070-06-07T03:24:38.454Z"
  },
  "fundamentalData": {
    "description": "foo",
    "lastUpdatedFA": {
      "$date": "2035-07-05T02:31:44.777Z"
    }
  }
}

Seth

1 Like