# Selective Field Importing With River

**URL:** <https://discuss.elastic.co/t/selective-field-importing-with-river/12322>\
**Category:** Elasticsearch\
**Created:** [June 7, 2013, 8:05pm UTC](https://discuss.elastic.co/t/selective-field-importing-with-river/12322 "2013-06-07T20:05:37Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mblodnick](https://avatars.discourse-cdn.com/v4/letter/m/73ab20/32.png) [@mblodnick](https://discuss.elastic.co/u/mblodnick)\
**Post date:** [June 7, 2013, 8:05pm UTC](https://discuss.elastic.co/t/selective-field-importing-with-river/12322/1 "2013-06-07T20:05:37Z")

</div>

I am currently using ElasticSearch to search through data stored in a mongo db. However I have come across an issue that I seem to be stuck on. I am using a river to build indices from my database, I want to exclude some data from being stored into the JSON document. I have some security sensitive information that I would prefer not to have on my server.

In fact, it would be more beneficial if I could just list the data fields that I want to be included and stored into the JSON document while still using a mongo db river-plugin. Please share any guidance you have on this problem.

Any advice is appreciated?

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [June 14, 2013, 3:57pm UTC](https://discuss.elastic.co/t/selective-field-importing-with-river/12322/2 "2013-06-14T15:57:35Z")

</div>

May be script filters is the way to go? See [Home · richardwilly98/elasticsearch-river-mongodb Wiki · GitHub](https://github.com/richardwilly98/elasticsearch-river-mongodb/wiki#script-filters)

--  
David Pilato | Technical Advocate | [Elasticsearch.com](http://Elasticsearch.com)  
@dadoonet | @elasticsearchfr | @scrutmydocs

Le 7 juin 2013 à 22:05, mblodnick [mblodnick@gmail.com](mailto:mblodnick@gmail.com) a écrit :

> I am currently using Elasticsearch to search through data stored in a mongo  
> db. However I have come across an issue that I seem to be stuck on. I am  
> using a river to build indices from my database, I want to exclude some data  
> from being stored into the JSON document. I have some security sensitive  
> information that I would prefer not to have on my server.
> 
> In fact, it would be more beneficial if I could just list the data fields  
> that I want to be included and stored into the JSON document while still  
> using a mongo db river-plugin. Please share any guidance you have on this  
> problem.
> 
> Any advice is appreciated?
> 
> --  
> View this message in context: [http://elasticsearch-users.115913.n3.nabble.com/Selective-Field-Importing-With-River-tp4036229.html](http://elasticsearch-users.115913.n3.nabble.com/Selective-Field-Importing-With-River-tp4036229.html)  
> Sent from the Elasticsearch Users mailing list archive at [Nabble.com](http://Nabble.com).
> 
> --  
> You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Sahana](https://avatars.discourse-cdn.com/v4/letter/s/5fc32e/32.png) [@Sahana](https://discuss.elastic.co/u/Sahana)\
**Post date:** [October 16, 2013, 11:23am UTC](https://discuss.elastic.co/t/selective-field-importing-with-river/12322/3 "2013-10-16T11:23:42Z")

</div>

I have been trying to combine a few conditions using logical operators in  
the script filter but, it doesn't seem to work

{  
"index": {  
"name": "myindex",  
"type": "mytype"  
},  
"\_enabled": true,  
"\_name": "myindex",  
"mongodb": {  
"db": "mydb",  
"servers": [  
{  
"port": 27017,  
"host": "127.0.0.1"  
}  
],  
"collection": "mycollection",  
"script": "ctx.deleted = (ctx.document.trash == 1 || ctx.document.private == 1)"  
},  
"type": "mongodb"  
}

I also tried -

"script": "if( ctx.document.trash == 1 || ctx.document.private == 1 ) { ctx.deleted = true; }"

but, it indexes even when one of the flags(trash/private) is 0. it doesn't  
seem to be taking the OR into consideration at all.

Is there something wrong with the above?

Note - Also tried defining a mongodb filter on the oplogs -

"filter": "{"o.private": 0, "o.trash":0}". But, this resulted in a parser  
exception.

On Friday, June 14, 2013 9:27:35 PM UTC+5:30, David Pilato wrote:

> May be script filters is the way to go? See  
> [Home · richardwilly98/elasticsearch-river-mongodb Wiki · GitHub](https://github.com/richardwilly98/elasticsearch-river-mongodb/wiki#script-filters)
> 
> --  
> _David Pilato_ | _Technical Advocate_ | _[Elasticsearch.com](http://Elasticsearch.com)_  
> @dadoonet [https://twitter.com/dadoonet](https://twitter.com/dadoonet) | @elasticsearchfr[https://twitter.com/elasticsearchfr](https://twitter.com/elasticsearchfr)  
> | @scrutmydocs [https://twitter.com/scrutmydocs](https://twitter.com/scrutmydocs)
> 
> Le 7 juin 2013 à 22:05, mblodnick \<[mblo...@gmail.com](mailto:mblo...@gmail.com) \<javascript:\>\> a  
> écrit :
> 
> I am currently using Elasticsearch to search through data stored in a mongo  
> db. However I have come across an issue that I seem to be stuck on. I am  
> using a river to build indices from my database, I want to exclude some  
> data  
> from being stored into the JSON document. I have some security sensitive  
> information that I would prefer not to have on my server.
> 
> In fact, it would be more beneficial if I could just list the data fields  
> that I want to be included and stored into the JSON document while still  
> using a mongo db river-plugin. Please share any guidance you have on this  
> problem.
> 
> Any advice is appreciated?
> 
> --  
> View this message in context:  
> [http://elasticsearch-users.115913.n3.nabble.com/Selective-Field-Importing-With-River-tp4036229.html](http://elasticsearch-users.115913.n3.nabble.com/Selective-Field-Importing-With-River-tp4036229.html)  
> Sent from the Elasticsearch Users mailing list archive at [Nabble.com](http://Nabble.com).
> 
> --  
> You received this message because you are subscribed to the Google Groups  
> "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an  
> email to [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com) \<javascript:\>.  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 6, 2017, 2:12am UTC](https://discuss.elastic.co/t/selective-field-importing-with-river/12322/4 "2017-07-06T02:12:10Z")

</div>


