Hi Wanted Some Help

The text about {"took":{"total":1,"successful":1,"skipped":1,"failed":1,"max_score":1,"hits":1},"timed_out":{"total":false,"successful":false,"skipped":false,"failed":false,"max_score":false,"hits":false},"_shards":{"total":1.0,"successful":1.0,"skipped":0.0,"failed":0.0,"max_score":null,"hits":null},"hits":{"total":{"value":0,"relation":"eq"},"successful":null,"skipped":null,"failed":null,"max_score":null,"hits":[]}}

with python pls help I Have to do it as my project has been paused

You will need to provide a lot more context around your setup, version used and exactly what you have done and what is not what you expect in order for anyone to be able to help you.

The thing I want to do is remove the text

I will be pasting the file.

from flask import *
from flask_restful import Api
from elasticsearch import Elasticsearch
es = Elasticsearch("http://localhost:9200")
from matches import search
import pandas
import spacy
from spacy.lang.en.stop_words import STOP_WORDS as stopwords
import json
import numpy as np
from add import add
from full_text import full_text
from multimatch import multi_match
from matchalles import search_all

app = Flask(name)
app.secret_key = 'kingom'
api = Api(app)

@app.route('/')
def home():
return render_template('home.html')

@app.route('/total' , methods =["GET", "POST"])
def get_all():
search_all()
return render_template('list.html')
@app.route('/all' , methods =["GET", "POST"])
def getall():
return search_all()

@app.route('/search' , methods =["GET", "POST"])
def search_speci():
global useranswer
global elastic_df
global search_inpt
# It Posts Request
if request.method=="POST":
# The search input check
search_inpt = request.form.get("seab")
# This is for checking elasticsearch for the search
response = es.search(index="location" , query={"match":{useranswer:search_inpt}})
# Starts for the returning
elastic_docs = response["hits"]["hits"]
# Printing the documents number which are found
print ("documents returned:", len(response["hits"]["hits"]))
# Changeing the output to Table then to normal json
fields = response
elastic_df = pandas.DataFrame(fields)
json_data = elastic_df.to_json()
# returning the json_data
return json_data
return render_template("searchab.html" )

@app.route('/add', methods =["GET", "POST"])
def add_docs():
global about_add
# Getting the values of user
if request.method == "POST":
about_add = request.form.get("about")
where_add = request.form.get("where")
# doc for adding
doc1 = {
"about": about_add,
"where": where_add
}
# code for adding docs
response = es.index(
index="location",
document=doc1,
id = number
)
return about_add , where_add
return render_template("add.html")

@app.route('/multi' , methods =["GET", "POST"])
def multi():
multi_match()
return render_template("multisearch.html")

@app.route('/fulltext' , methods =["GET", "POST"])
def fulltext():
# creating stages and appling filters to it
if request.method=="POST":
# data = es.search(index="location" , query={"match_all":{}})
data = search_inpt = request.form.get("speci")
# Defining the dataframe and using it
df = pandas.DataFrame(data=data)
stage2 = df.apply(lambda x: len(str(x).split()))
stage3 = stage2.apply(lambda x: cont_to_exp(x))
stage4 = stage3.apply(lambda x: re.sub(r'[^\w ]+', "", x))
stage5 = stage4.apply(lambda x: ' '.join(x.split()))
response = es.search(index="location" , query={"match":{"where": stage5}})
# Changeing the output to Table then to normal json
fields = response
elastic_df = pandas.DataFrame(fields)
json_data = elastic_df.to_json()
# returning the json_data
return json_data
return render_template("searchwh.html")
@app.route('/update' , methods =["GET", "POST"])
def update():
global about_update
# Getting the values of user
if request.method == "POST":
about_update = request.form.get("about")
where_update = request.form.get("where")
user_id = request.form.get("user_id")

# doc for adding
    doc1 = {
        "about": about_update,
        "where": where_update
    }
# code for adding docs
    response = es.index(
         index="location",
         document=doc1,
         id = user_id
        )
    return "About and Where Updated", doc1
return render_template('update.html')

@app.route('/delete' , methods =["GET", "POST"])
def delete():
if request.method=="POST":
search_inpt = request.form.get("dele")
dele = es.delete(index = "location",id = search_inpt)
search()
return "The Doc Has Been Successfully Deleted"
return render_template('delete.html')
if name == 'main':
app.run(port=5000, debug=True)

{"took":{"total":4,"successful":4,"skipped":4,"failed":4,"max_score":4,"hits":4},"timed_out":{"total":false,"successful":false,"skipped":false,"failed":false,"max_score":false,"hits":false},"_shards":{"total":1.0,"successful":1.0,"skipped":0.0,"failed":0.0,"max_score":null,"hits":null},"hits":{"total":{"value":1,"relation":"eq"},"successful":null,"skipped":null,"failed":null,"max_score":1.0,"hits":[{"_index":"location","_id":"1","_score":1.0,"_source":{"about":"Om","where":"Bombay"}}]}}

I only want this :[{"_index":"location","_id":"1","_score":1.0,"_source":{"about":"Om","where":"Bombay"}}]}}

You need to explain the problem, your setup/mappings/configuration and what you are looking to achieve and not just paste messages and code if you want anyone here to help. I am not a Python developer and most people will not read through your code and try to guess what you are doing and what is wrong.

oh ok

well the mapping is
location index
fields : about and where

then next we have is the setup the device is Mac
Elasticsearch version is 8.0.0
python version 3.10
And the code is using python and Elasticsearch
if any changes pls tell

This is not very useful. Please show the full mappings for the index.

This gives us the version you are using. OS and Python version is from my perspective irrelevant. You have still not explained what you are looking to achieve and exactly what is not working. I volunteer my time here and do not have the time nor energy to play question and answer ping-pong, so if you can not take the time to properly describe this I will leave it to someone else to try.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.