# Simple cloudant word search by timestamp - need help

**URL:** https://discourse.nodered.org/t/simple-cloudant-word-search-by-timestamp-need-help/8384
**Category:** General
**Created:** [25 February 2019 23:12 UTC](https://discourse.nodered.org/t/simple-cloudant-word-search-by-timestamp-need-help/8384 "2019-02-25T23:12:49Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![bryan-ninjamoba](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bryan-ninjamoba/32/21973_2.png) [@bryan-ninjamoba](https://discourse.nodered.org/u/bryan-ninjamoba)
#### Post date: [25 February 2019 23:12 UTC](https://discourse.nodered.org/t/simple-cloudant-word-search-by-timestamp-need-help/8384/1 "2019-02-25T23:12:49Z")

</div>

My cloudant database was created with the following: msg.payload via tweetnode to cloudant

```auto
{ 
   "timestamp" : msg.tweet.timestamp_ms, 
   "tweet" : msg.tweet.text, 
   "sentiment" : msg.sentiment.score
}

```

**I would like to search the tweet field by word and timestamp by a range of dates. Then save the results by tagging the tweets found back to cloudant via node-red**.

This seems like a routine thing people do. I have not found any flows that do this. Help is appreciated - especially a link to a working search by text using cloudant flow!

---

<div class="post-metadata">

### Author: ![bryan-ninjamoba](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bryan-ninjamoba/32/21973_2.png) [@bryan-ninjamoba](https://discourse.nodered.org/u/bryan-ninjamoba)
#### Post date: [26 February 2019 01:55 UTC](https://discourse.nodered.org/t/simple-cloudant-word-search-by-timestamp-need-help/8384/2 "2019-02-26T01:55:45Z")

</div>

The index I am using is this

function(doc) {  
index("default", doc.\_id);  
if (doc.timestamp) {  
index("timestamp", doc.timestamp, {"store": true});  
}  
if (doc.tweet) {  
index("tweet", doc.tweet, {"store": true});  
}  
if (doc.sentiment) {  
index("sentiment", doc.sentiment, {"store": true});  
}  
}

---

<div class="post-metadata">

### Author: ![bryan-ninjamoba](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bryan-ninjamoba/32/21973_2.png) [@bryan-ninjamoba](https://discourse.nodered.org/u/bryan-ninjamoba)
#### Post date: [26 February 2019 01:59 UTC](https://discourse.nodered.org/t/simple-cloudant-word-search-by-timestamp-need-help/8384/3 "2019-02-26T01:59:22Z")

</div>

Here is the very simple flow :  
I need the correct .json to access searching by text

```auto
[{"id":"d97b9063.f8ed5","type":"tab","label":"SeachbyTimestamptweet","disabled":false,"info":""},{"id":"ee136fe.41b259","type":"function","z":"d97b9063.f8ed5","name":"Selector","func":" msg.payload = {\n query: \"tweet : sometext<string>\",\n }\n \n\nreturn msg;","outputs":1,"noerr":0,"x":496.5,"y":326,"wires":[["6886370a.572098","c7a70ad1.dfd8c8"]]},{"id":"6886370a.572098","type":"debug","z":"d97b9063.f8ed5","name":"","active":true,"console":"true","complete":"payload","x":759.5,"y":300,"wires":[]},{"id":"ab27b442.879dc8","type":"debug","z":"d97b9063.f8ed5","name":"dashDB Output","active":true,"console":"false","complete":"payload","x":918.5,"y":370,"wires":[]},{"id":"b16088c.b8a1a78","type":"inject","z":"d97b9063.f8ed5","name":"","topic":"","payload":"","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":"","x":261,"y":249,"wires":[["ee136fe.41b259"]]},{"id":"c7a70ad1.dfd8c8","type":"cloudant in","z":"d97b9063.f8ed5","name":"timestamp/tweet","cloudant":"98949ae5.b3cdd8","database":"tweetdata","service":"Cloudant-Twitter #Esports Collector","search":"_idx_","design":"newViewsAll","index":"IndexALL","x":698,"y":392,"wires":[["ab27b442.879dc8"]]},{"id":"94f1242a.c9c8f8","type":"comment","z":"d97b9063.f8ed5","name":"Search pattern","info":"","x":243.00003051757812,"y":612.0000076293945,"wires":[]},{"id":"98949ae5.b3cdd8","type":"cloudant","z":"","host":"myaccountname.cloudant.com","name":"My Cloudant account"}]

```
