Skip to main content

404 HEAD issue when creating AWS Elasticsearch index

I am trying to create my first index using python and I keep getting a 404 index not found exception. Here is the current code:

es = Elasticsearch([{'host': 'host_url', 'port': 443, 'use_ssl': True, 'timeout': 300}])

if es.indices.exists('test_logs'):
    es.indices.delete(index = 'test_logs')

request_body = {
    'settings': {
        'number_of_shards': 2,
        'number_of_relicas': 2
    },
    'mappings': {
        'logs': {
            'properties': {
                'date': { 'index': 'not_analyzed', 'type': 'date' },
                'time': { 'index': 'not_analyzed', 'type': 'time' },
                'request': { 'index': 'not_analyzed', 'type': 'string' },
                'status': { 'index': 'not_analyzed', 'type': 'int' },
                'agent': { 'index': 'not_analyzed', 'type': 'string' }
            }
        }
    }
}

es.indices.create(index = 'test_logs', ignore = [400, 404], body = request_body, request_timeout = 30)

EDIT: I have changed some things and now I get a different error. I have updated my code and title for the new issue. Here is my output:

C:\Python34\lib\site-packages\elasticsearch\connection\http_urllib3.py:54: UserW
arning: Connecting to host_url using SSL with verify_certs=False is insecure.
  'Connecting to %s using SSL with verify_certs=False is insecure.' % host)
C:\Python34\lib\site-packages\urllib3\connectionpool.py:789: InsecureRequestWarn
ing: Unverified HTTPS request is being made. Adding certificate verification is
strongly advised. See: https://urllib3.readthedocs.org/en/latest/security.html
  InsecureRequestWarning)
HEAD /test_logs [status:404 request:0.902s]
C:\Python34\lib\site-packages\urllib3\connectionpool.py:789: InsecureRequestWarn
ing: Unverified HTTPS request is being made. Adding certificate verification is
strongly advised. See: https://urllib3.readthedocs.org/en/latest/security.html
  InsecureRequestWarning)
Press any key to continue . . .

What does the HEAD /test_logs 404 mean?

Solved

Changed my connection to:

es = Elasticsearch(
    hosts = host,
    connection_class = RequestsHttpConnection,
    port = 443,
    use_ssl = True,
    verify_certs = False)

Works fine now. Do not know why the previous one failed.


Comments

Popular posts from this blog

How to grab a certain data from Array?

I am new to Javascript / Ionic so I try to wrap my head around different concepts. I have a function that retrieve the users like this : $timeout(function(){ $scope.users = snapshot1.val(); console.log($scope.users); }) Which gives me the information in the console. Now, I would like to isolate the field "name" but when I do : snapshot1.val().name; It does not work. Is there a way to grab only a specific field ? Solved console.log(snapshot1.val().map(el=>el.name)); If its really an Array, you can generate a new Array containing just the name property using Array.prototype.map...

What is the right way to pass a value from the UI to another thread?

I have the MainActivity thread which contains a Fragment class. The purpose of that fragment is to allow user to connect to a Bluetooth device. After the user is connected the ConnectedThread starts its while loop which is listening to incoming bytes. In the MainActivity I have a Boolean value which changes based on whether checkbox is checked or not. I would like to pass that value from the MainActivity to that while loop when it changes. So the question is, what is the right way to do that? Is there any trick like a handler for that? Or should I pass the context to the ConnectedThread and then set a listener for that in the ConnectedThread class? Solved you can use interface as callback here. declare an interface in your MainActivity and have your class with connected thread implement it. once value changes in MainActivity trigger the callback method and you can pass your variable as a parameter to other class.