0

I recently created some search documents and added them to a custom search index using the following which generates an index per user for the model type.

    def _post_put_hook(self, future):

    document = self.create_search_document()
    index = self.search_index
    index.put(document)

However I noticed that in the admin panel there is an index for my model type that seems to be always automatically generated and added to. Is this correct?

Admin Panel: Full Text Search: Image shows the top indexes are the ones I am creating while the bottom one has been made automatically.

If so how would I got about cleaning up the document that gets added to this when the corresponding entities are deleted? (I clean up my own index using a delete hook).

1 Answers1

0

No, Search API doesn't create an index automatically.

Maybe the index has been created during development, i.e. at some point, your code used a different name pattern for these indices.

In the Google Cloud Developer console, click on that index. You should be able to see and search documents in this index. If it is empty, or it has old documents, then my theory would explain this.

If the index contains up-to-date documents, maybe there is a part of your code causing this behavior and you are just not aware of it. If the code above is the only one that writes documents into search, then you should investigate if self.search_index somehow is redefined during handling a request.

One more note though:

You can delete all documents in an index in Search API, but you cannot delete the index itself (at least not the last time I checked the docs).

Ani
  • 1,377
  • 1
  • 18
  • 29
  • Thanks I'll do another review and see if I can spot anywhere that it might be happening. It seems to occur only when the model is first created, updates only change my index. As for your note about number of indices I found this line in the documentation [There is no limit to the number of documents in an index or the number of indexes you can use](https://cloud.google.com/appengine/docs/python/search/#Python_Overview). Maybe it used to be limited? – Brad_Mclain Nov 22 '15 at 21:08
  • Yes, indeed, they've removed the limit on the number of indexes. This is great. I will update my answer to reflect this. – Ani Nov 23 '15 at 22:51