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
  • Navigate entity relationships with agentic graph search

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.",
    "enable_agentic_graph": true
  }'

Search Parameters

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

ParameterDescriptionDefaultRecommended
queryThe search query textRequiredUse 2-3 detailed sentences
enable_agentic_graphEnable intelligent entity-aware searchfalsetrue (HIGHLY RECOMMENDED)
max_memoriesMaximum number of memory items to return2015-20 for comprehensive coverage
max_nodesMaximum number of graph nodes to return1510-15 for entity relationships
rank_resultsWhether to enable additional ranking of search resultsfalsefalse (results already ranked)

Enhancing Search Relevance

Using agentic graph search enables much more intelligent, context-aware 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": "Find all product roadmap discussions that mention the mobile app redesign. Include any timeline estimates or resource allocations.",
    "enable_agentic_graph": true
  }'

2. Use Appropriate Result Limits

Setting proper max_memories and max_nodes values ensures comprehensive coverage:

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": 20,
    "max_nodes": 15,
    "enable_agentic_graph": true
  }'

3. Write Detailed, Specific Queries

The more detail in your query, the better the 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": "Find discussions from our planning meetings in March where we specifically talked about the Q2 launch timeline for the mobile app redesign. I need details about any dependencies or risks that were identified.",
    "enable_agentic_graph": true
  }'

4. Filter by Metadata

Use metadata to narrow down 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": "Find product discussions about performance improvements",
    "metadata": {
      "hierarchical_structures": "Product/Performance",
      "topics": ["performance", "optimization"]
    },
    "enable_agentic_graph": true
  }'

Working with Search Results

1. Processing Memories and Nodes

When agentic graph search is enabled, you'll receive both memories and graph nodes:

function processSearchResults(response) {
  // Process memory content
  const memories = response.data.memories;
  console.log(`Found ${memories.length} relevant memories`);
  
  // Process graph nodes
  const nodes = response.data.nodes;
  console.log(`Found ${nodes.length} related entities`);
  
  // Group nodes by type
  const peopleNodes = nodes.filter(node => node.label === 'Person');
  const projectNodes = nodes.filter(node => node.label === 'Project');
  const taskNodes = nodes.filter(node => node.label === 'Task');
  
  console.log(`Found ${peopleNodes.length} people, ${projectNodes.length} projects, and ${taskNodes.length} tasks`);
  
  return {
    memories,
    people: peopleNodes.map(n => n.properties),
    projects: projectNodes.map(n => n.properties),
    tasks: taskNodes.map(n => n.properties)
  };
}

2. Providing Search Feedback

Improve future search results by providing feedback:

def submit_search_feedback(client, search_id, is_helpful, comments=None):
    """Submit feedback for a search result to help improve future results"""
    feedback_response = client.feedback.submit(
        search_id=search_id,
        feedback_data={
            "feedback_type": "thumbs_up" if is_helpful else "thumbs_down",
            "feedback_source": "inline",
            "feedback_text": comments
        }
    )
    
    return feedback_response.feedback_id

# After performing a search
search_response = client.memory.search(
    query="Find product roadmap discussions",
    enable_agentic_graph=True
)

# Save the search_id for later feedback
search_id = search_response.search_id

# Later, after user reviews results, submit feedback
feedback_id = submit_search_feedback(
    client, 
    search_id, 
    is_helpful=True,
    comments="Found exactly the roadmap information I needed"
)

Best Practices for Search Optimization

1. Enable Agentic Graph

Always set enable_agentic_graph: true for:

  • Intelligent, context-aware search
  • Understanding ambiguous references
  • Navigating entity relationships
  • Comprehensive memory coverage

2. Use Descriptive Queries

For better results:

  • Write 2-3 sentences that clearly describe what you're looking for
  • Include specific details like names, dates, topics
  • Explain the context of your search
  • Specify time frames when applicable

3. Optimize Result Size

Set appropriate limits:

  • max_memories: 15-20 for comprehensive coverage
  • max_nodes: 10-15 for entity relationships
  • Use smaller values only when specifically targeting a limited set of results

4. Provide Feedback

After each search, provide feedback to improve results:

  • Submit thumbs up/down via the feedback API
  • Provide specific comments about why results were helpful or not
  • Note which memories were most relevant

Next Steps