i am looking for a way to search for specific fields in a document using marqo because whenever i use the .search()
method the _highlights
returns a random field either the title, description or any other field but it is usually random.
this is an example of what i mean:
{
'hits': [
{
'Title': 'document_title',
'Description': 'document_description',
'_highlights': {
'Description': 'document_description'
},
'_id': 'document_id',
'_score': document_score
},
{
'Title': 'document_title',
'Description': "document_description",
'_highlights': {'Title': 'document_title'},
'_id': 'document_id',
'_score': document_score
}
],
'limit': 10,
'processingTimeMs': 49,
'query': 'search_query'
}
as you can see the first documents _highlights
is Description while the second is title i want a way to make it uniform.
i think the best way of getting specific fields when using marqo is by add a keyword argument to the search method which is searchable_attributes=[]
then you pass the fields you want to list as a string.
eg.
result = mq.index("your_index").search('query', searchable_attributes=['Title', 'Description'])