0

I am indexing data into Elasticsearch. I do not know what is "sort". I have not put it in the mapping and it is neither in the data that I am indexing.

Why does it appear?

THIS IS MY CODE

def initialize_mapping(es):
    mapping_classification = {
        'properties': {
            '@timestamp': {'type': 'date'},
            'Labels': {'type': 'keyword'},
            'Model': {'type': 'keyword'},
            'Image': {'type': 'keyword'},
            'Time(ms)': {'type': 'short'},
            'Inference': {'type': 'text'},
            'Score': {'type': 'short'},
            'TPU_temp(°C)': {'type': 'short'}
        }
    }
    print("Initializing the mapping ...")  
    if not es.indices.exists(INDEX_NAME):
        es.indices.create(INDEX_NAME)
        es.indices.put_mapping(body=mapping_classification, doc_type=DOC_TYPE, index=INDEX_NAME)



def main():

    es=initialize_elasticsearch()
    initialize_mapping(es)    


    actions = [
        {
            '_index': INDEX_NAME,
            '_type': DOC_TYPE,
            "@timestamp": str(datetime.datetime.utcnow().strftime("%Y-%m-%d"'T'"%H:%M:%S")),
            "Labels": maX_group[0].split(":")[1],
            "Model": maX_group[1].split(":")[1],
            "Image": maX_group[2].split(":")[1],
            "Time(ms)": maX_group[4].split(":")[1],
            "Inference": maX_group[5].split(":")[1],
            "Score": maX_group[6].split(":")[1],
            "TPU_temp(°C)": maX_group[7].split(":")[1]
        
        }]
   


    try:
        res=helpers.bulk(client=es, index = INDEX_NAME, actions = actions)
        print ("\nhelpers.bulk() RESPONSE:", res)
        print ("RESPONSE TYPE:", type(res))
        
    except Exception as err:
        print("\nhelpers.bulk() ERROR:", err)


if __name__ == "__main__":
    main()

enter image description here

Aizzaac
  • 3,146
  • 8
  • 29
  • 61
  • How are you printing out that document? `sort` is just the sort value for that document returned by the search query you've made – Val Jul 17 '20 at 16:40
  • I do not undesrtand the question. But this is related to this: ```https://stackoverflow.com/questions/62459572/how-can-i-read-data-from-a-list-and-index-specific-values-into-elasticsearch-us/62460512?noredirect=1#comment110837766_62460512``` – Aizzaac Jul 17 '20 at 16:49
  • In the devboard I have a list from which I extracted values accoding to a best Score. Then that list I indexed into Elasticsearch. – Aizzaac Jul 17 '20 at 16:50
  • 1
    As I understand you're probably in the Discover view in KIbana and you've "opened" a document to see its content. The document content that you have sent to Elasticsearch is in the `_source` part. What you see in `sort` is simply the `@timestamp` long value of your document (since documents are sorted by @timestamp in the Discover view) – Val Jul 17 '20 at 16:59
  • ok, but it was not appearing before. For example in this other link (the last image): ```https://stackoverflow.com/questions/62778983/compressor-detection-can-only-be-called-on-some-xcontent-bytes-or-compressed-xc``` – Aizzaac Jul 17 '20 at 17:04
  • 1
    Ok, but I don't understand what the issue is? that `sort` value is not in your document at all. Only what you see in `_source` is actually your document. In your other question, you might have created an index-pattern without specifying any @timestamp field, and hence the documents where not sorted in the Discover view – Val Jul 17 '20 at 17:28
  • You are right. I was having problems with the 'timestamp' . I was just curious to know :) – Aizzaac Jul 17 '20 at 17:34

1 Answers1

1

That sort value is not in your document at all. Only what you see in _source is actually your document.

In your other question, you might have created an index-pattern without specifying any @timestamp field, and hence the documents where not sorted in the Discover view and you didn't see any sort value.

Val
  • 207,596
  • 13
  • 358
  • 360
  • Actually I was not able to specify the @timestamp using Bulk. I was always ending with 2 mappings. So now I am only sending 1 group of data (sorting the best group with the best "Score") instead of many. – Aizzaac Jul 17 '20 at 22:11
  • I'm not sure I understand what you mean by "not able to specify the @timestamp using Bulk" – Val Jul 18 '20 at 04:07
  • That problem is related to this question: ```https://stackoverflow.com/questions/62778983/compressor-detection-can-only-be-called-on-some-xcontent-bytes-or-compressed-xc``` Even though I can index data, I end up with 2 mappings: the one defined by me and the other by elasticsearch. – Aizzaac Jul 24 '20 at 17:53