So, I am trying to create a flask api that gets the name of the field of search and the term that we are going to search, then, the script writes the info into a file and uses subprocess to run a search, see:
file = open("filtro_match.json")
filtro = file.read()
file.close()
lista = word.split("|")
filtro = filtro.replace("$campo",str(lista[0]))
filtro = filtro.replace("$busca",str(lista[1]))
#return "Ok"
file = open("filtro_match_temp.json", "w")
file.write(filtro)
file.close()
resultado = subprocess.check_output('curl -XGET "localhost:9200/pessoas/_search?pretty" -H "Content-Type: application/json" --data @filtro_match_temp.json')
temp = resultado.decode('utf-8')
obj = json.loads(temp)
However, everytime that I try to run it,I receive this error:
"type" : "json_parse_exception",
"reason" : "Invalid UTF-8 middle byte 0x22\n at [Source: org.elasticsearch.transport.netty4.ByteBufStreamInput@f868020; line: 1, column: 39]"
I have no idea from where this "Invalid UTF-8 middle byte" came from, I write the file with python, can someone help me out?