Search for a message

Introduced 2.12

Retrieves message information for conversational search. You can send queries to the _search endpoint to search for matching messages within a memory.

When the Security plugin is enabled, all memories exist in a private security mode. Only the user who created a memory can interact with that memory and its messages.

Path and HTTP methods

  1. POST /_plugins/_ml/memory/<memory_id>/_search
  2. GET /_plugins/_ml/memory/<memory_id>/_search

Path parameters

The following table lists the available path parameters.

ParameterData typeDescription
memory_idStringThe ID of the memory used to search for messages matching the query.

Example request

  1. GET /_plugins/_ml/memory/gW8Aa40BfUsSoeNTvOKI/_search
  2. {
  3. "query": {
  4. "match": {
  5. "input": "interaction"
  6. }
  7. }
  8. }

copy

Example response

  1. {
  2. "took": 5,
  3. "timed_out": false,
  4. "_shards": {
  5. "total": 1,
  6. "successful": 1,
  7. "skipped": 0,
  8. "failed": 0
  9. },
  10. "hits": {
  11. "total": {
  12. "value": 1,
  13. "relation": "eq"
  14. },
  15. "max_score": 0.47000366,
  16. "hits": [
  17. {
  18. "_index": ".plugins-ml-memory-message",
  19. "_id": "BW8ha40BfUsSoeNT8-i3",
  20. "_version": 1,
  21. "_seq_no": 0,
  22. "_primary_term": 1,
  23. "_score": 0.47000366,
  24. "_source": {
  25. "input": "How do I make an interaction?",
  26. "memory_id": "gW8Aa40BfUsSoeNTvOKI",
  27. "trace_number": null,
  28. "create_time": "2024-02-02T18:43:23.566994302Z",
  29. "additional_info": {
  30. "suggestion": "api.openai.com"
  31. },
  32. "response": "Hello, this is OpenAI. Here is the answer to your question.",
  33. "origin": "MyFirstOpenAIWrapper",
  34. "parent_message_id": null,
  35. "prompt_template": "Hello OpenAI, can you answer this question?"
  36. }
  37. }
  38. ]
  39. }
  40. }

Response fields

For information about response fields, see Create Message request fields.