I am making an api in python to link it with elasticsearch but when executing it, it generates an error on line 23 res['ST'] = search_term which translates as 'ObjectApiResponse' object does not support item assignment, I appreciate your help and collaboration from flask import Flask, render_template, request from elasticsearch import Elasticsearch import os os.chdir('/home/ambu/Documents/search') app: Flask = Flask(__name__, template_folder='templates') es = Elasticsearch("http://127.0.0.1:9200") @app.route('/') def index(): return render_template('search.html') @app.route('/search/results', methods=['GET', 'POST']) def request_search(): search_term = request.form["input"] res = es.search( index='data_example4', body={ "query": {"match": {"content": search_term}}, "highlight": {"pre_tags": ["<b>"], "post_tags": ["</b>"], "fields": {"content": {}}}}) res['ST'] = search_term for hit in res['hits']['hits']: hit['good_summary'] = '….'.join(hit['highlight']['content'][1:]) return render_template('results.html', res=res) if __name__ == '__main__': app.run('127.0.0.1', debug=True) Thank you for your help to solve this problem. Continue reading...