Last updated

Search Tuning Guide

This guide explains how to optimize memory search results in Papr Memory to get the most accurate and relevant results for your specific use case.

Papr Memory's search capabilities allow you to:

  • Find memories based on semantic meaning (not just keyword matching)
  • Retrieve both memory items and graph nodes with a single query
  • Control the number of results returned
  • Optimize ranking for specific use cases

Query Format Best Practices

For optimal search results, queries should be detailed and specific, rather than just a few keywords:

  • Use 2-3 sentences that clearly describe what you're looking for
  • Include specific details such as names, dates, or technical terms
  • Provide context about why you're searching for this information
  • Specify time frames when relevant (e.g., "from last quarter" or "in the past month")

Example of an effective query:

Find the most recent product roadmap discussion from our planning meetings last quarter. I'm particularly interested in the AI feature priorities and timeline estimates that were discussed.

Example of a poor query:

product roadmap

The more detailed your query, the better the semantic search engine can understand your intent and return relevant results.

Basic Search Syntax

The search operation requires a query string:

curl -X POST "https://memory.papr.ai/v1/memory/search" \
  -H "X-API-Key: YOUR_API_KEY" \
  -H "Accept-Encoding: gzip" \
  -H "Content-Type: application/json" \
  -H "X-Client-Type: curl" \
  -d '{
    "query": "Find notes from our quarterly budget meeting where we discussed department allocations for Q3. Include any decisions about marketing spending."
  }'

Search Parameters

Customize your search with these parameters to improve relevance for your specific needs:

ParameterDescriptionDefaultExample
queryThe search query textRequired"Find our latest product roadmap discussions from Q1 planning meetings. I need information about feature priorities and release timelines."
max_memoriesMaximum number of memory items to return2050
max_nodesMaximum number of graph nodes to return1530
rank_resultsWhether to enable additional ranking of search resultsfalsetrue

Enhancing Search Relevance

1. Write Detailed, Specific Queries

Creating detailed queries significantly improves search quality:

curl -X POST "https://memory.papr.ai/v1/memory/search" \
  -H "X-API-Key: YOUR_API_KEY" \
  -H "Accept-Encoding: gzip" \
  -H "Content-Type: application/json" \
  -H "X-Client-Type: curl" \
  -d '{
    "query": "Find all product roadmap discussions that mention the mobile app redesign. Include any timeline estimates or resource allocations."
  }'

2. Control Result Size

Use max_memories and max_nodes to adjust how many results to return:

curl -X POST "https://memory.papr.ai/v1/memory/search" \
  -H "X-API-Key: YOUR_API_KEY" \
  -H "Accept-Encoding: gzip" \
  -H "Content-Type: application/json" \
  -H "X-Client-Type: curl" \
  -d '{
    "query": "Find all detailed roadmap discussions about upcoming features and release schedules.",
    "max_memories": 15,
    "max_nodes": 5
  }'

3. Result Ranking

For specialized use cases, you can enable additional ranking of search results:

curl -X POST "https://memory.papr.ai/v1/memory/search" \
  -H "X-API-Key: YOUR_API_KEY" \
  -H "Accept-Encoding: gzip" \
  -H "Content-Type: application/json" \
  -H "X-Client-Type: curl" \
  -d '{
    "query": "Locate discussions about our annual report preparation. Include mentions of financial metrics and submission deadlines.",
    "rank_results": true
  }'

The rank_results parameter enables additional ranking of search results. Default is false because results are already ranked when using an LLM for search (recommended approach). Only enable this if you're not using an LLM in your search pipeline and need additional result ranking.

Common Search Patterns and Use Cases

Find specific information with a highly detailed query:

search_response = client.memory.search(
    query="Find all marketing strategy documents from the past month that discuss our social media campaigns. Include any performance metrics or ROI analysis mentioned.",
    max_memories=20
)

2. Balancing Memory and Graph Results

Adjust the ratio of memory items to graph nodes:

search_response = client.memory.search(
    query="Find all discussions about product features and technical requirements for the new mobile platform. Include any diagrams or specifications mentioned.",
    max_memories=10,
    max_nodes=20  # Prioritize graph connections
)

When you need just the most relevant items:

search_response = client.memory.search(
    query="Find the most recent discussion about the Q2 budget approval for the marketing department. I need to know the exact approved amount.",
    max_memories=5,
    max_nodes=0  # Only interested in memory items, not graph nodes
)

Best Practices for Search Tuning

  1. Start broad, then refine - Begin with simple queries and add detail as needed.

  2. Use descriptive queries - Write 2-3 sentence detailed queries that describe what you're looking for, including specific details, context, and time frames.

  3. Balance memory and graph results - Adjust max_memories and max_nodes based on your use case.

  4. Be specific about time - Include time frames in your queries when relevant (e.g., "from last quarter" or "in the past month").

  5. Include "Accept-Encoding: gzip" header for improved performance with large responses.

Troubleshooting Search Issues

Not getting expected results?

  1. Improve your query format - Make sure your query is detailed (2-3 sentences) and includes specific context
  2. Try more specific queries - Add more detail and context to your search query
  3. Increase max_memories - Try retrieving more results if important items might be missing
  4. Use different phrasings - Try rephrasing your query to use different terminology

Too many irrelevant results?

  1. Use more specific queries - Add more detail to your search query
  2. Reduce max_memories - Retrieve fewer, more relevant results
  3. Enable rank_results - Try turning on additional result ranking
  4. Be more specific with timeframes - Include specific date ranges in your query text

Next Steps