If you have a Mac:
Open Terminal.
Browse to your Messages directory. Replace 'jimmy' with your username. If not sure, browse to the Users directory first to confirm what it is.
cd /Users/jimmy/Library/Messages
Next run a program that allows you to interact with the database containing your chat messages:
sqlite3 chat.db
sqlite program opens and gives you its own command prompt. Enter the following replacing the number with the number of the contact you want to search on. Actual contact names like 'Jill' are not stored in the db, so you have to use their phone number (if that doesn't work, maybe try their email if that's all you have for the contact. Replace the example text, Apple, with your own keyword or phrase. Leave the % signs as they tell the program to search for the word or phrase at any location within the message like so:
select text from message join handle on message.handle_id = handle.ROWID where handle.id = '+19344968775' and message.text like '%apples%';
If you got the phone number right and there are results for your search you will see the content of the text on the next line, like so:
Please buy apples
To exit:
sqlite> .exit