Вопрос

I'm having some trouble getting elastic search integrated with an existing application, but it should be a fairly straightforward issue. I'm able to create and destroy indices but for some reason I'm having trouble getting data into elastic search and querying for it.

I'm using the pyes library and honestly finding the documentation to be less than helpful on this front. This is my current code:

def initialize_transcripts(database, mapping):
    database.indices.create_index("transcript-index")


def index_course(database, sjson_directory, course_name, mapping):
    database.put_mapping(course_name, {'properties': mapping}, "transcript-index")
    all_transcripts = grab_transcripts(sjson_directory)
    video_counter = 0
    for transcript_tuple in all_transcripts:
        data_map = {"searchable_text": transcript_tuple[0], "uuid": transcript_tuple[1]}
        database.index(data_map, "transcript-index", course_name, video_counter)
        video_counter += 1
    database.indices.refresh("transcript-index")


def search_course(database, query, course_name):
    search_query = TermQuery("searchable_text", query)
    return database.search(query=search_query) 

I'm first creating the database, and initializing the index, then trying to add data in and search it with the second two methods. I'm currently getting the following error:

raise ElasticSearchException(response.body, response.status, response.body)
pyes.exceptions.ElasticSearchException: No handler found for uri [/transcript-index/test-course] and method [PUT]

I'm not quite sure how to approach it, and the only reference I could find to this error suggested creating your index beforehand which I believe I am already doing. Has anyone run into this error before? Alternatively do you know of any good places to look that I might not be aware of?

Any help is appreciated.

Это было полезно?

Решение

For some reason, adding the ID to the index, despite the fact that it is shown in the starting documentation: (http://pyes.readthedocs.org/en/latest/manual/usage.html) doesn't work, and in fact causes this error.

Once I removed the video_counter argument to index, this worked perfectly.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top