I started indexing. Then I changed my code to include additional fields but the new fields are "not indexed" according to Kibana. How do I make the new fields indexed as well?
Thank you
What does the mapping look like?
Also, it helps others help you if you have a better topic
Hello. Thank you. This is the code
import json from tweepy.streaming import StreamListener from tweepy import
OAuthHandler from tweepy import Stream from textblob import TextBlob from
elasticsearch import Elasticsearch # import twitter keys and tokens from
config import * # create instance of elasticsearch es = Elasticsearch()
class TweetStreamListener(StreamListener): # on success def on_data(self,
data): # decode json dict_data = json.loads(data) # pass tweet into
TextBlob tweet = TextBlob(dict_data["text"]) # output sentiment polarity
print tweet.sentiment.polarity # determine if sentiment is positive,
negative, or neutral if tweet.sentiment.polarity < 0: sentiment =
"negative" elif tweet.sentiment.polarity == 0: sentiment = "neutral" else:
sentiment = "positive" # output sentiment print sentiment # add text and
sentiment info to elasticsearch es.index(index="sentiment",
doc_type="test-type", body={"author": dict_data["user"]["screen_name"],
"date": dict_data["created_at"], "message": dict_data["text"], "polarity":
tweet.sentiment.polarity, "subjectivity": tweet.sentiment.subjectivity,
"sentiment": sentiment}) return True # on failure def on_error(self,
status): print status if name == 'main': # create instance of the
tweepy tweet stream listener listener = TweetStreamListener() # set twitter
keys/tokens auth = OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_token_secret) # create instance
of the tweepy stream stream = Stream(auth, listener) # search twitter for
"congress" keyword stream.filter(track=['congress'])
It'd help if you could format it properly, use the </>
button.
I tried to add in an id field for the tweet. According to Twitter
The integer representation of the unique identifier for this Tweet. This
number is greater than 53 bits and some programming languages may have
difficulty/silent defects in interpreting it. Using a signed 64 bit integer
for storing this identifier is safe. Use id_str for fetching the identifier
to stay on the safe side. SeeTwitter
https://dev.twitter.com/overview/api/twitter-ids-json-and-snowflake IDs,
https://dev.twitter.com/overview/api/twitter-ids-json-and-snowflakeJSON
https://dev.twitter.com/overview/api/twitter-ids-json-and-snowflake and
Snowflake
https://dev.twitter.com/overview/api/twitter-ids-json-and-snowflake.
Example:
"id":114749583439036416
Hello. Thank you. This is the code
import json from tweepy.streaming import StreamListener from tweepy import
OAuthHandler from tweepy import Stream from textblob import TextBlob from
elasticsearch import Elasticsearch # import twitter keys and tokens from
config import * # create instance of elasticsearch es = Elasticsearch()
class TweetStreamListener(StreamListener): # on success def on_data(self,
data): # decode json dict_data = json.loads(data) # pass tweet into
TextBlob tweet = TextBlob(dict_data["text"]) # output sentiment polarity
print tweet.sentiment.polarity # determine if sentiment is positive,
negative, or neutral if tweet.sentiment.polarity < 0: sentiment =
"negative" elif tweet.sentiment.polarity == 0: sentiment = "neutral" else:
sentiment = "positive" # output sentiment print sentiment # add text and
sentiment info to elasticsearch es.index(index="sentiment",
doc_type="test-type", body={"author": dict_data["user"]["screen_name"],
"date": dict_data["created_at"], "message": dict_data["text"], "polarity":
tweet.sentiment.polarity, "subjectivity": tweet.sentiment.subjectivity,
"sentiment": sentiment}) return True # on failure def on_error(self,
status): print status if name == 'main': # create instance of the
tweepy tweet stream listener listener = TweetStreamListener() # set twitter
keys/tokens auth = OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_token_secret) # create instance
of the tweepy stream stream = Stream(auth, listener) # search twitter for
"congress" keyword stream.filter(track=['congress'])