Search code examples
mongodbsolrdataimporthandler

how to prevent a document getting indexed during full import?


I have a mongodb collection which i would like to index on solr using data import handler . But i don't want the documents with foodType(a field in document) as variant to get indexed during full import how to do it?


Solution

  • If you have the query to get the documents from the MongoDB. Then modify that query by adding a filtering condition. This filter will not retreive the data from mongoDB where the documents has foodType.

    e.g

    db.collection.find({ "fieldToCheck" : { $exists : true, $ne : null } })
    

    You can add some conditions as above in your query and restrict the data from being indexed in solr.

    In the data-config the query is missing and that is the reason its getting all the documents from mongoDB. If you add the query with correct criteria it will retrive selected documents.

    For more on the mongo Query please refer the link below

    MOngoDB reference link