conversations
listlengths
3
3
metadata
dict
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: Marketing Campaigns\n\nField Mappings:\n{\n \"properties\": {\n \"ticketId\": {\n \"type\": \"keyword\"\n },\n \"productId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"description\": {\n \"type\": \"text\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"priority\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"assignee\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"price\": {\n \"type\": \"float\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"ticketId\": \"TCK-001\",\n \"productId\": \"PRD-1001\",\n \"title\": \"Spring Sale Email Blast\",\n \"description\": \"Create and schedule email campaign for spring discount.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"email\",\n \"assignee\": \"alice\",\n \"createdAt\": \"2025-10-01T09:15:00Z\",\n \"price\": 0\n },\n {\n \"ticketId\": \"TCK-002\",\n \"productId\": \"PRD-1002\",\n \"title\": \"Social Media Ads for New Product\",\n \"description\": \"Design and launch Facebook and Instagram ads.\",\n \"status\": \"in_progress\",\n \"priority\": \"medium\",\n \"category\": \"social\",\n \"assignee\": \"bob\",\n \"createdAt\": \"2025-09-28T14:30:00Z\",\n \"price\": 1500\n },\n {\n \"ticketId\": \"TCK-003\",\n \"productId\": \"PRD-1003\",\n \"title\": \"Landing Page Optimization\",\n \"description\": \"A/B test landing page copy and layout.\",\n \"status\": \"resolved\",\n \"priority\": \"low\",\n \"category\": \"seo\",\n \"assignee\": \"carol\",\n \"createdAt\": \"2025-09-20T11:45:00Z\",\n \"price\": 0\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Show open high‑priority tickets assigned to Alice\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, retrieving the requested tickets...\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"List all resolved tickets from March in the email category\",\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": [\n {\n \"term\": {\n \"status\": \"resolved\"\n }\n },\n {\n \"range\": {\n \"createdAt\": {\n \"gte\": \"2025-03-01\",\n \"lt\": \"2025-04-01\"\n }\n }\n },\n {\n \"term\": {\n \"category\": \"email\"\n }\n }\n ]\n }\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n }\n]\n\nUser Query: Show open high‑priority tickets assigned to Alice\n\nRephrased Query: List open tickets with high priority assigned to Alice\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": [\n {\n \"term\": {\n \"status\": \"open\"\n }\n },\n {\n \"term\": {\n \"priority\": \"high\"\n }\n },\n {\n \"term\": {\n \"assignee\": \"alice\"\n }\n }\n ]\n }\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n}" } ]
{ "domain": "Marketing Campaigns", "data_type": "structured", "query_type": "listing_with_filters", "pattern": "initial", "pattern_type": "categorical_listing", "size": 10, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: Legal Documents\n\nField Mappings:\n{\n \"properties\": {\n \"documentId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"author\": {\n \"type\": \"keyword\"\n },\n \"department\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"fileType\": {\n \"type\": \"keyword\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"tags\": {\n \"type\": \"keyword\"\n },\n \"confidentialityLevel\": {\n \"type\": \"keyword\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"documentId\": \"DOC-001\",\n \"title\": \"IT Security Policy\",\n \"author\": \"Alice Johnson\",\n \"department\": \"IT Security\",\n \"createdAt\": \"2023-11-15T09:30:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"policy\",\n \"tags\": [\n \"security\",\n \"access\",\n \"encryption\"\n ],\n \"confidentialityLevel\": \"internal\"\n },\n {\n \"documentId\": \"DOC-002\",\n \"title\": \"Finance Quarterly Report Q1 2024\",\n \"author\": \"Bob Martinez\",\n \"department\": \"Finance\",\n \"createdAt\": \"2024-04-20T14:00:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"draft\",\n \"category\": \"report\",\n \"tags\": [\n \"quarterly\",\n \"revenue\",\n \"expenses\"\n ],\n \"confidentialityLevel\": \"confidential\"\n },\n {\n \"documentId\": \"DOC-003\",\n \"title\": \"Remote Work Guidelines\",\n \"author\": \"Carol Lee\",\n \"department\": \"Human Resources\",\n \"createdAt\": \"2024-01-10T08:45:00Z\",\n \"fileType\": \"docx\",\n \"status\": \"approved\",\n \"category\": \"guideline\",\n \"tags\": [\n \"remote\",\n \"policy\",\n \"equipment\"\n ],\n \"confidentialityLevel\": \"public\"\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"List PDFs from Finance department after 2024\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, retrieving PDF documents from Finance created after Jan 1, 2024.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"List PDFs from Finance department after 2024\",\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": [\n {\n \"term\": {\n \"fileType\": \"pdf\"\n }\n },\n {\n \"term\": {\n \"department\": \"Finance\"\n }\n },\n {\n \"range\": {\n \"createdAt\": {\n \"gte\": \"2024-01-01T00:00:00Z\"\n }\n }\n }\n ]\n }\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n }\n]\n\nUser Query: Show approved policies from IT Security\n\nRephrased Query: List approved policy documents from the IT Security department\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": [\n {\n \"term\": {\n \"status\": \"approved\"\n }\n },\n {\n \"term\": {\n \"category\": \"policy\"\n }\n },\n {\n \"term\": {\n \"department\": \"IT Security\"\n }\n }\n ]\n }\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n}" } ]
{ "domain": "Legal Documents", "data_type": "unstructured", "query_type": "listing_with_filters", "pattern": "refinement", "pattern_type": "narrow_scope", "size": 10, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: Academic Articles\n\nField Mappings:\n{\n \"properties\": {\n \"documentId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"author\": {\n \"type\": \"keyword\"\n },\n \"department\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"fileType\": {\n \"type\": \"keyword\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"tags\": {\n \"type\": \"keyword\"\n },\n \"confidentialityLevel\": {\n \"type\": \"keyword\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"documentId\": \"doc-001\",\n \"title\": \"Security Policies for Remote Work\",\n \"author\": \"Dr. Alice Smith\",\n \"department\": \"IT Security\",\n \"createdAt\": \"2024-03-15T09:30:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"policy\",\n \"tags\": [\n \"security\",\n \"remote\",\n \"policy\"\n ],\n \"confidentialityLevel\": \"internal\"\n },\n {\n \"documentId\": \"doc-002\",\n \"title\": \"Financial Reporting Guidelines 2024\",\n \"author\": \"John Doe\",\n \"department\": \"Finance\",\n \"createdAt\": \"2024-01-20T11:00:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"draft\",\n \"category\": \"guideline\",\n \"tags\": [\n \"finance\",\n \"reporting\"\n ],\n \"confidentialityLevel\": \"confidential\"\n },\n {\n \"documentId\": \"doc-003\",\n \"title\": \"Data Privacy Regulations Overview\",\n \"author\": \"Dr. Emily Zhang\",\n \"department\": \"Legal\",\n \"createdAt\": \"2023-12-05T14:45:00Z\",\n \"fileType\": \"docx\",\n \"status\": \"approved\",\n \"category\": \"regulation\",\n \"tags\": [\n \"privacy\",\n \"data\",\n \"regulation\"\n ],\n \"confidentialityLevel\": \"public\"\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Can you list the latest security policies?\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, here are the most recent approved security policies...\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"Show 10 recent documents\",\n \"dsl_type\": \"simple_match\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"match_all\": {}\n }\n }\n }\n]\n\nUser Query: $Show $24 approved policies from IT Security\n\nRephrased Query: Retrieve 24 approved policy documents from the IT Security department\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"hybrid_search_with_filters\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 24,\n \"from\": 0,\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"text_expansion\": {\n \"model_id\": \"text-embedding-ada-002\",\n \"model_text\": \"approved policy IT Security\"\n }\n },\n {\n \"knn\": {\n \"field\": \"documentContentWordsChunked.embedding\",\n \"query_vector\": [\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0\n ],\n \"k\": 24,\n \"num_candidates\": 100\n }\n }\n ],\n \"filter\": {\n \"bool\": {\n \"must\": [\n {\n \"term\": {\n \"status\": \"approved\"\n }\n },\n {\n \"term\": {\n \"department\": \"IT Security\"\n }\n }\n ]\n }\n }\n }\n }\n }\n}" } ]
{ "domain": "Academic Articles", "data_type": "unstructured", "query_type": "hybrid_search_with_filters", "pattern": "initial", "pattern_type": "categorical_listing", "size": 24, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: Technical Manuals\n\nField Mappings:\n{\n \"properties\": {\n \"documentId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"author\": {\n \"type\": \"keyword\"\n },\n \"department\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"fileType\": {\n \"type\": \"keyword\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"tags\": {\n \"type\": \"keyword\"\n },\n \"confidentialityLevel\": {\n \"type\": \"keyword\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"documentId\": \"TM-001\",\n \"title\": \"IT Security Policy Overview\",\n \"author\": \"alice.smith\",\n \"department\": \"IT Security\",\n \"createdAt\": \"2023-05-12T08:30:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"policy\",\n \"tags\": [\n \"security\",\n \"policy\",\n \"overview\"\n ],\n \"confidentialityLevel\": \"internal\"\n },\n {\n \"documentId\": \"TM-002\",\n \"title\": \"Finance Department Expense Guidelines\",\n \"author\": \"bob.johnson\",\n \"department\": \"Finance\",\n \"createdAt\": \"2024-01-20T14:15:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"draft\",\n \"category\": \"guideline\",\n \"tags\": [\n \"expense\",\n \"finance\",\n \"guidelines\"\n ],\n \"confidentialityLevel\": \"confidential\"\n },\n {\n \"documentId\": \"TM-003\",\n \"title\": \"Remote Work Security Checklist\",\n \"author\": \"carol.lee\",\n \"department\": \"IT Security\",\n \"createdAt\": \"2024-07-03T10:00:00Z\",\n \"fileType\": \"docx\",\n \"status\": \"approved\",\n \"category\": \"checklist\",\n \"tags\": [\n \"remote\",\n \"security\",\n \"checklist\"\n ],\n \"confidentialityLevel\": \"public\"\n },\n {\n \"documentId\": \"TM-004\",\n \"title\": \"HR Employee Onboarding Process\",\n \"author\": \"david.kim\",\n \"department\": \"Human Resources\",\n \"createdAt\": \"2023-11-11T09:45:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"process\",\n \"tags\": [\n \"onboarding\",\n \"HR\",\n \"process\"\n ],\n \"confidentialityLevel\": \"internal\"\n },\n {\n \"documentId\": \"TM-005\",\n \"title\": \"IT Infrastructure Upgrade Plan 2025\",\n \"author\": \"emma.wilson\",\n \"department\": \"IT Operations\",\n \"createdAt\": \"2024-09-15T16:20:00Z\",\n \"fileType\": \"pptx\",\n \"status\": \"planned\",\n \"category\": \"plan\",\n \"tags\": [\n \"infrastructure\",\n \"upgrade\",\n \"2025\"\n ],\n \"confidentialityLevel\": \"confidential\"\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Show approved policies from IT Security\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, I will retrieve the approved policies belonging to the IT Security department.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"List PDFs from Finance department after 2024\",\n \"dsl_type\": \"hybrid_search_with_filters\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"query\": {\n \"hybrid\": {\n \"text_expansion\": {\n \"title\": {\n \"model_id\": \"semantic-model-1\",\n \"model_text\": \"PDF documents\"\n }\n },\n \"filter\": {\n \"bool\": {\n \"must\": [\n {\n \"term\": {\n \"department\": \"Finance\"\n }\n },\n {\n \"term\": {\n \"fileType\": \"pdf\"\n }\n },\n {\n \"range\": {\n \"createdAt\": {\n \"gt\": \"2024-01-01\"\n }\n }\n }\n ]\n }\n }\n }\n }\n }\n }\n]\n\nUser Query: Show approved policies from IT Security\n\nRephrased Query: List approved policy documents in the IT Security department\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"hybrid_search_with_filters\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 10,\n \"from\": 10,\n \"query\": {\n \"hybrid\": {\n \"text_expansion\": {\n \"title\": {\n \"model_id\": \"semantic-model-1\",\n \"model_text\": \"approved policies\"\n }\n },\n \"filter\": {\n \"bool\": {\n \"must\": [\n {\n \"term\": {\n \"status\": \"approved\"\n }\n },\n {\n \"term\": {\n \"department\": \"IT Security\"\n }\n }\n ]\n }\n }\n }\n }\n }\n}" } ]
{ "domain": "Technical Manuals", "data_type": "unstructured", "query_type": "hybrid_search_with_filters", "pattern": "pagination", "pattern_type": "previous_page", "size": 10, "from": 10, "is_pagination": true }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: News Articles\n\nField Mappings:\n{\n \"properties\": {\n \"documentId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"author\": {\n \"type\": \"keyword\"\n },\n \"department\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"fileType\": {\n \"type\": \"keyword\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"tags\": {\n \"type\": \"keyword\"\n },\n \"confidentialityLevel\": {\n \"type\": \"keyword\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"documentId\": \"doc-001\",\n \"title\": \"Quarterly Financial Report Q1 2024\",\n \"author\": \"Jane Smith\",\n \"department\": \"Finance\",\n \"createdAt\": \"2024-04-15T09:30:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"report\",\n \"tags\": [\n \"finance\",\n \"quarterly\",\n \"2024\"\n ],\n \"confidentialityLevel\": \"internal\"\n },\n {\n \"documentId\": \"doc-002\",\n \"title\": \"IT Security Policy Update\",\n \"author\": \"Mark Lee\",\n \"department\": \"IT Security\",\n \"createdAt\": \"2024-02-20T14:00:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"policy\",\n \"tags\": [\n \"security\",\n \"policy\",\n \"update\"\n ],\n \"confidentialityLevel\": \"confidential\"\n },\n {\n \"documentId\": \"doc-003\",\n \"title\": \"Remote Work Guidelines\",\n \"author\": \"Emily Davis\",\n \"department\": \"Human Resources\",\n \"createdAt\": \"2023-12-05T11:15:00Z\",\n \"fileType\": \"docx\",\n \"status\": \"draft\",\n \"category\": \"guideline\",\n \"tags\": [\n \"remote\",\n \"work\",\n \"guidelines\"\n ],\n \"confidentialityLevel\": \"public\"\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Show me the latest approved policies from IT Security.\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, retrieving approved policy documents from the IT Security department.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"Show recent articles\",\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": []\n }\n },\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n }\n]\n\nUser Query: List PDFs from Finance department after 2024\n\nRephrased Query: List PDF documents where department is Finance and createdAt is on or after 2024-01-01\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 10,\n \"from\": 30,\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": [\n {\n \"term\": {\n \"fileType\": \"pdf\"\n }\n },\n {\n \"term\": {\n \"department\": \"Finance\"\n }\n },\n {\n \"range\": {\n \"createdAt\": {\n \"gte\": \"2024-01-01\"\n }\n }\n }\n ]\n }\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n}" } ]
{ "domain": "News Articles", "data_type": "unstructured", "query_type": "listing_with_filters", "pattern": "pagination", "pattern_type": "next_page", "size": 10, "from": 30, "is_pagination": true }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: Customer Profiles\n\nField Mappings:\n{\n \"properties\": {\n \"customerId\": {\n \"type\": \"keyword\"\n },\n \"name\": {\n \"type\": \"text\"\n },\n \"email\": {\n \"type\": \"keyword\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"priority\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"assignee\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"price\": {\n \"type\": \"float\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"customerId\": \"CUST001\",\n \"name\": \"Alice Johnson\",\n \"email\": \"[email protected]\",\n \"status\": \"active\",\n \"priority\": \"high\",\n \"category\": \"enterprise\",\n \"assignee\": \"sales_team_a\",\n \"createdAt\": \"2024-09-12T08:15:30Z\",\n \"price\": 1250.75,\n \"documentContentWordsChunked\": [\n {\n \"passage\": \"Alice is a long‑term enterprise client interested in premium support.\",\n \"embedding\": [\n 0,\n 0,\n 0\n ]\n }\n ]\n },\n {\n \"customerId\": \"CUST002\",\n \"name\": \"Bob Smith\",\n \"email\": \"[email protected]\",\n \"status\": \"inactive\",\n \"priority\": \"low\",\n \"category\": \"small_business\",\n \"assignee\": \"account_manager_b\",\n \"createdAt\": \"2023-05-03T14:42:10Z\",\n \"price\": 300,\n \"documentContentWordsChunked\": [\n {\n \"passage\": \"Bob recently cancelled his subscription due to budget constraints.\",\n \"embedding\": [\n 0,\n 0,\n 0\n ]\n }\n ]\n },\n {\n \"customerId\": \"CUST003\",\n \"name\": \"Carol Lee\",\n \"email\": \"[email protected]\",\n \"status\": \"active\",\n \"priority\": \"medium\",\n \"category\": \"mid_market\",\n \"assignee\": \"sales_team_c\",\n \"createdAt\": \"2024-02-20T11:07:45Z\",\n \"price\": 750.2,\n \"documentContentWordsChunked\": [\n {\n \"passage\": \"Carol is evaluating upgrade options for her mid‑market account.\",\n \"embedding\": [\n 0,\n 0,\n 0\n ]\n }\n ]\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Show me 10 customer profiles\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Here are the first 10 customer profiles matching your request.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"Show me 10 customer profiles\",\n \"dsl_type\": \"listing\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"match_all\": {}\n }\n }\n }\n]\n\nUser Query: Show me 36 customer profiles\n\nRephrased Query: list 36 customer profiles without any filters\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"listing\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 36,\n \"from\": 0,\n \"query\": {\n \"match_all\": {}\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n}" } ]
{ "domain": "Customer Profiles", "data_type": "structured", "query_type": "listing", "pattern": "initial", "pattern_type": "listing", "size": 36, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: Supplier Contracts\n\nField Mappings:\n{\n \"properties\": {\n \"ticketId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"description\": {\n \"type\": \"text\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"priority\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"assignee\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"price\": {\n \"type\": \"float\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"ticketId\": \"SC-1001\",\n \"title\": \"Network Infrastructure Upgrade Contract\",\n \"description\": \"Contract for upgrading the supplier's network infrastructure across all regions.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"network\",\n \"assignee\": \"tech_support\",\n \"createdAt\": \"2024-09-12T08:15:30Z\",\n \"price\": 125000\n },\n {\n \"ticketId\": \"SC-1002\",\n \"title\": \"Annual Maintenance Agreement\",\n \"description\": \"Yearly maintenance contract for supplier equipment.\",\n \"status\": \"closed\",\n \"priority\": \"medium\",\n \"category\": \"maintenance\",\n \"assignee\": \"operations\",\n \"createdAt\": \"2024-03-05T14:22:10Z\",\n \"price\": 45000\n },\n {\n \"ticketId\": \"SC-1003\",\n \"title\": \"Software Licensing Renewal\",\n \"description\": \"Renewal of software licenses for supplier's ERP system.\",\n \"status\": \"in_progress\",\n \"priority\": \"low\",\n \"category\": \"software\",\n \"assignee\": \"legal\",\n \"createdAt\": \"2024-07-20T11:45:00Z\",\n \"price\": 30000\n },\n {\n \"ticketId\": \"SC-1004\",\n \"title\": \"Supply Chain Risk Assessment\",\n \"description\": \"Assessment of risks in the supplier's supply chain.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"risk\",\n \"assignee\": \"risk_management\",\n \"createdAt\": \"2024-10-01T09:30:45Z\",\n \"price\": 80000\n },\n {\n \"ticketId\": \"SC-1005\",\n \"title\": \"Logistics Optimization Project\",\n \"description\": \"Project to optimize logistics for supplier deliveries.\",\n \"status\": \"closed\",\n \"priority\": \"medium\",\n \"category\": \"logistics\",\n \"assignee\": \"logistics_team\",\n \"createdAt\": \"2024-02-18T16:05:20Z\",\n \"price\": 60000\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Show open tickets\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Here are the open tickets...\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"List open tickets\",\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": [\n {\n \"term\": {\n \"status\": \"open\"\n }\n }\n ]\n }\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n }\n]\n\nUser Query: List high-priority network tickets assigned to tech support\n\nRephrased Query: Show high priority network tickets assigned to tech support\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 10,\n \"from\": 10,\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": [\n {\n \"term\": {\n \"priority\": \"high\"\n }\n },\n {\n \"term\": {\n \"category\": \"network\"\n }\n },\n {\n \"term\": {\n \"assignee\": \"tech_support\"\n }\n }\n ]\n }\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n}" } ]
{ "domain": "Supplier Contracts", "data_type": "structured", "query_type": "listing_with_filters", "pattern": "pagination", "pattern_type": "previous_page", "size": 10, "from": 10, "is_pagination": true }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: Sales Orders\n\nField Mappings:\n{\n \"properties\": {\n \"ticketId\": {\n \"type\": \"keyword\"\n },\n \"productId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"description\": {\n \"type\": \"text\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"priority\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"assignee\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"price\": {\n \"type\": \"float\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"ticketId\": \"TCK-1001\",\n \"productId\": \"PRD-2001\",\n \"title\": \"Network latency issue\",\n \"description\": \"Customer reports intermittent latency on VPN connections.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"network\",\n \"assignee\": \"tech_support\",\n \"createdAt\": \"2025-10-20T08:15:30Z\",\n \"price\": 0,\n \"documentContentWordsChunked\": [\n {\n \"passage\": \"Network latency issue details...\",\n \"embedding\": [\n 0.1,\n 0.2,\n 0\n ]\n }\n ]\n },\n {\n \"ticketId\": \"TCK-1002\",\n \"productId\": \"PRD-2002\",\n \"title\": \"Invoice discrepancy\",\n \"description\": \"The invoice amount does not match the quoted price.\",\n \"status\": \"resolved\",\n \"priority\": \"medium\",\n \"category\": \"billing\",\n \"assignee\": \"accounting\",\n \"createdAt\": \"2025-09-15T14:42:10Z\",\n \"price\": 1250.75,\n \"documentContentWordsChunked\": [\n {\n \"passage\": \"Invoice discrepancy details...\",\n \"embedding\": [\n 0.3,\n 0.4,\n 0\n ]\n }\n ]\n },\n {\n \"ticketId\": \"TCK-1003\",\n \"productId\": \"PRD-2003\",\n \"title\": \"New product order\",\n \"description\": \"Order placed for 50 units of the new model.\",\n \"status\": \"open\",\n \"priority\": \"low\",\n \"category\": \"order\",\n \"assignee\": \"sales_rep\",\n \"createdAt\": \"2025-11-01T10:05:45Z\",\n \"price\": 7500,\n \"documentContentWordsChunked\": [\n {\n \"passage\": \"New product order details...\",\n \"embedding\": [\n 0.5,\n 0.6,\n 0\n ]\n }\n ]\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Show open tickets\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, retrieving all tickets with status open.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"List high-priority network tickets assigned to tech support\",\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": [\n {\n \"term\": {\n \"priority\": \"high\"\n }\n },\n {\n \"term\": {\n \"category\": \"network\"\n }\n },\n {\n \"term\": {\n \"assignee\": \"tech_support\"\n }\n }\n ]\n }\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n }\n]\n\nUser Query: Show open tickets\n\nRephrased Query: Retrieve all tickets where status is open\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": [\n {\n \"term\": {\n \"status\": \"open\"\n }\n }\n ]\n }\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n}" } ]
{ "domain": "Sales Orders", "data_type": "structured", "query_type": "listing_with_filters", "pattern": "initial", "pattern_type": "categorical_listing", "size": 10, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: Product Ticket Catalog\n\nField Mappings:\n{\n \"properties\": {\n \"ticketId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"description\": {\n \"type\": \"text\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"priority\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"assignee\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"price\": {\n \"type\": \"float\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"ticketId\": \"TCK-1001\",\n \"title\": \"Network latency issue\",\n \"description\": \"Users experience high latency on the corporate VPN.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"network\",\n \"assignee\": \"tech_support\",\n \"createdAt\": \"2024-10-12T08:15:30Z\",\n \"price\": 0,\n \"documentContentWordsChunked\": []\n },\n {\n \"ticketId\": \"TCK-1002\",\n \"title\": \"Software license renewal\",\n \"description\": \"Renewal of Adobe Creative Cloud licenses for design team.\",\n \"status\": \"closed\",\n \"priority\": \"medium\",\n \"category\": \"software\",\n \"assignee\": \"procurement\",\n \"createdAt\": \"2024-09-05T14:42:10Z\",\n \"price\": 1200,\n \"documentContentWordsChunked\": []\n },\n {\n \"ticketId\": \"TCK-1003\",\n \"title\": \"Printer malfunction\",\n \"description\": \"Office printer prints blank pages intermittently.\",\n \"status\": \"open\",\n \"priority\": \"low\",\n \"category\": \"hardware\",\n \"assignee\": \"it_support\",\n \"createdAt\": \"2024-11-01T09:07:45Z\",\n \"price\": 0,\n \"documentContentWordsChunked\": []\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Show tickets\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Here are the first 10 tickets in the catalog.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"Show tickets\",\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": []\n }\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n }\n]\n\nUser Query: List open high-priority network tickets assigned to tech support\n\nRephrased Query: Retrieve open tickets with high priority in the network category that are assigned to the tech_support team\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": [\n {\n \"term\": {\n \"status\": \"open\"\n }\n },\n {\n \"term\": {\n \"priority\": \"high\"\n }\n },\n {\n \"term\": {\n \"category\": \"network\"\n }\n },\n {\n \"term\": {\n \"assignee\": \"tech_support\"\n }\n }\n ]\n }\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n}" } ]
{ "domain": "Product Ticket Catalog", "data_type": "structured", "query_type": "listing_with_filters", "pattern": "initial", "pattern_type": "complex_query", "size": 10, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: Project Management Tasks\n\nField Mappings:\n{\n \"properties\": {\n \"ticketId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"description\": {\n \"type\": \"text\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"priority\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"assignee\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"price\": {\n \"type\": \"float\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"ticketId\": \"TCK-001\",\n \"title\": \"Setup project repository\",\n \"description\": \"Create a new Git repository for the Alpha project and configure branch protection.\",\n \"status\": \"open\",\n \"priority\": \"medium\",\n \"category\": \"infrastructure\",\n \"assignee\": \"alice\",\n \"createdAt\": \"2025-10-20T09:15:00Z\",\n \"price\": 0\n },\n {\n \"ticketId\": \"TCK-002\",\n \"title\": \"Design UI mockups\",\n \"description\": \"Produce high‑fidelity mockups for the dashboard screens.\",\n \"status\": \"in_progress\",\n \"priority\": \"high\",\n \"category\": \"design\",\n \"assignee\": \"bob\",\n \"createdAt\": \"2025-10-18T14:30:00Z\",\n \"price\": 1500\n },\n {\n \"ticketId\": \"TCK-003\",\n \"title\": \"Implement authentication\",\n \"description\": \"Add OAuth2 login flow using the company SSO provider.\",\n \"status\": \"resolved\",\n \"priority\": \"high\",\n \"category\": \"development\",\n \"assignee\": \"carol\",\n \"createdAt\": \"2025-09-30T11:45:00Z\",\n \"price\": 2500\n },\n {\n \"ticketId\": \"TCK-004\",\n \"title\": \"Conduct security audit\",\n \"description\": \"Perform a penetration test on the new API endpoints.\",\n \"status\": \"open\",\n \"priority\": \"critical\",\n \"category\": \"security\",\n \"assignee\": \"dave\",\n \"createdAt\": \"2025-10-22T08:00:00Z\",\n \"price\": 3000\n },\n {\n \"ticketId\": \"TCK-005\",\n \"title\": \"Prepare release notes\",\n \"description\": \"Compile changelog for version 1.2.0 and distribute to stakeholders.\",\n \"status\": \"closed\",\n \"priority\": \"low\",\n \"category\": \"documentation\",\n \"assignee\": \"eve\",\n \"createdAt\": \"2025-09-25T16:20:00Z\",\n \"price\": 0\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Show tickets\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, retrieving the latest tickets for you.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"show tickets\",\n \"dsl_type\": \"listing\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"match_all\": {}\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ],\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n }\n }\n }\n]\n\nUser Query: Show tickets\n\nRephrased Query: List tickets without any filters\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"listing\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"match_all\": {}\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n}" } ]
{ "domain": "Project Management Tasks", "data_type": "structured", "query_type": "listing", "pattern": "initial", "pattern_type": "sorted_listing", "size": 10, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: Customer Support Tickets\n\nField Mappings:\n{\n \"properties\": {\n \"documentId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"author\": {\n \"type\": \"keyword\"\n },\n \"department\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"fileType\": {\n \"type\": \"keyword\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"tags\": {\n \"type\": \"keyword\"\n },\n \"confidentialityLevel\": {\n \"type\": \"keyword\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"documentId\": \"TCKT-001\",\n \"title\": \"Invoice discrepancy for Q1\",\n \"author\": \"alice.smith\",\n \"department\": \"Finance\",\n \"createdAt\": \"2024-02-15T09:30:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"open\",\n \"category\": \"billing\",\n \"tags\": [\n \"invoice\",\n \"q1\",\n \"discrepancy\"\n ],\n \"confidentialityLevel\": \"internal\"\n },\n {\n \"documentId\": \"TCKT-002\",\n \"title\": \"Access request for HR portal\",\n \"author\": \"bob.jones\",\n \"department\": \"HR\",\n \"createdAt\": \"2023-11-20T14:12:00Z\",\n \"fileType\": \"docx\",\n \"status\": \"closed\",\n \"category\": \"access\",\n \"tags\": [\n \"hr\",\n \"portal\",\n \"access\"\n ],\n \"confidentialityLevel\": \"confidential\"\n },\n {\n \"documentId\": \"TCKT-003\",\n \"title\": \"Server outage incident report\",\n \"author\": \"carol.lee\",\n \"department\": \"IT\",\n \"createdAt\": \"2024-01-05T22:45:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"resolved\",\n \"category\": \"incident\",\n \"tags\": [\n \"server\",\n \"outage\",\n \"report\"\n ],\n \"confidentialityLevel\": \"restricted\"\n },\n {\n \"documentId\": \"TCKT-004\",\n \"title\": \"Policy update: Remote work guidelines\",\n \"author\": \"dave.kim\",\n \"department\": \"IT Security\",\n \"createdAt\": \"2024-03-10T08:00:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"policy\",\n \"tags\": [\n \"remote\",\n \"work\",\n \"guidelines\"\n ],\n \"confidentialityLevel\": \"public\"\n },\n {\n \"documentId\": \"TCKT-005\",\n \"title\": \"Expense reimbursement request\",\n \"author\": \"eve.wong\",\n \"department\": \"Finance\",\n \"createdAt\": \"2023-12-30T11:20:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"pending\",\n \"category\": \"expense\",\n \"tags\": [\n \"reimbursement\",\n \"expense\"\n ],\n \"confidentialityLevel\": \"internal\"\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Can you show me the latest security policies?\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, here are the most recent security policy documents.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"Find all open tickets in the Finance department\",\n \"dsl_type\": \"hybrid_search_with_filters\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"hybrid\": {\n \"vector\": {\n \"field\": \"documentContentWordsChunked.embedding\",\n \"query_vector\": [\n 0\n ],\n \"k\": 10\n },\n \"filter\": {\n \"bool\": {\n \"must\": [\n {\n \"term\": {\n \"status\": \"open\"\n }\n },\n {\n \"term\": {\n \"department\": \"Finance\"\n }\n }\n ]\n }\n }\n }\n },\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n }\n }\n }\n]\n\nUser Query: List PDFs from Finance department after 2024\n\nRephrased Query: Retrieve PDF tickets from the Finance department created after January 1, 2024\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"hybrid_search_with_filters\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"hybrid\": {\n \"vector\": {\n \"field\": \"documentContentWordsChunked.embedding\",\n \"query_vector\": [\n 0\n ],\n \"k\": 10\n },\n \"filter\": {\n \"bool\": {\n \"must\": [\n {\n \"term\": {\n \"fileType\": \"pdf\"\n }\n },\n {\n \"term\": {\n \"department\": \"Finance\"\n }\n },\n {\n \"range\": {\n \"createdAt\": {\n \"gte\": \"2024-01-01\"\n }\n }\n }\n ]\n }\n }\n }\n }\n }\n}" } ]
{ "domain": "Customer Support Tickets", "data_type": "unstructured", "query_type": "hybrid_search_with_filters", "pattern": "initial", "pattern_type": "keyword_search", "size": 10, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: HR Employee Records\n\nField Mappings:\n{\n \"properties\": {\n \"ticketId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"description\": {\n \"type\": \"text\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"priority\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"assignee\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"salary\": {\n \"type\": \"double\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"ticketId\": \"HR-001\",\n \"title\": \"Benefits enrollment issue\",\n \"description\": \"Employee cannot enroll in health benefits for the upcoming year.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"Benefits\",\n \"assignee\": \"john.doe\",\n \"createdAt\": \"2024-10-01T08:15:30Z\",\n \"salary\": 75000\n },\n {\n \"ticketId\": \"HR-002\",\n \"title\": \"Payroll discrepancy\",\n \"description\": \"Incorrect overtime payment on last month’s paycheck.\",\n \"status\": \"resolved\",\n \"priority\": \"medium\",\n \"category\": \"Payroll\",\n \"assignee\": \"jane.smith\",\n \"createdAt\": \"2024-09-20T14:42:10Z\",\n \"salary\": 82000\n },\n {\n \"ticketId\": \"HR-003\",\n \"title\": \"Access request for HR portal\",\n \"description\": \"New hire needs access to the employee self‑service portal.\",\n \"status\": \"open\",\n \"priority\": \"low\",\n \"category\": \"Onboarding\",\n \"assignee\": \"john.doe\",\n \"createdAt\": \"2024-10-05T11:03:45Z\",\n \"salary\": 68000\n },\n {\n \"ticketId\": \"HR-004\",\n \"title\": \"Leave balance correction\",\n \"description\": \"Annual leave balance not updated after recent vacation.\",\n \"status\": \"in_progress\",\n \"priority\": \"high\",\n \"category\": \"Leave Management\",\n \"assignee\": \"alice.wang\",\n \"createdAt\": \"2024-09-28T09:27:00Z\",\n \"salary\": 77000\n },\n {\n \"ticketId\": \"HR-005\",\n \"title\": \"Employee data privacy request\",\n \"description\": \"Request to delete personal data per GDPR.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"Compliance\",\n \"assignee\": \"john.doe\",\n \"createdAt\": \"2024-10-03T16:58:20Z\",\n \"salary\": 88000\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Show open tickets assigned to John.\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Here are the open tickets currently assigned to John.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"Show open tickets assigned to John.\",\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": [\n {\n \"term\": {\n \"status\": \"open\"\n }\n },\n {\n \"term\": {\n \"assignee\": \"john.doe\"\n }\n }\n ]\n }\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n }\n]\n\nUser Query: List open HR tickets assigned to John in the Benefits category\n\nRephrased Query: Show open tickets where assignee is john.doe and category is Benefits\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 10,\n \"from\": 10,\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": [\n {\n \"term\": {\n \"status\": \"open\"\n }\n },\n {\n \"term\": {\n \"assignee\": \"john.doe\"\n }\n },\n {\n \"term\": {\n \"category\": \"Benefits\"\n }\n }\n ]\n }\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n}" } ]
{ "domain": "HR Employee Records", "data_type": "structured", "query_type": "listing_with_filters", "pattern": "pagination", "pattern_type": "specific_page", "size": 10, "from": 10, "is_pagination": true }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: Marketing Campaigns\n\nField Mappings:\n{\n \"properties\": {\n \"ticketId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"description\": {\n \"type\": \"text\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"priority\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"assignee\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"price\": {\n \"type\": \"float\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"ticketId\": \"TCK-001\",\n \"title\": \"Spring Sale Email Blast\",\n \"description\": \"Create and schedule email campaign for Spring promotion.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"email\",\n \"assignee\": \"alice.smith\",\n \"createdAt\": \"2024-09-12T08:15:30Z\",\n \"price\": 0,\n \"documentContentWordsChunked\": [\n {\n \"passage\": \"Spring Sale Email Blast content draft...\",\n \"embedding\": null\n }\n ]\n },\n {\n \"ticketId\": \"TCK-002\",\n \"title\": \"Facebook Ads for New Product\",\n \"description\": \"Design ad creatives and set targeting for the new product launch.\",\n \"status\": \"in_progress\",\n \"priority\": \"medium\",\n \"category\": \"social_media\",\n \"assignee\": \"bob.jones\",\n \"createdAt\": \"2024-09-10T14:42:10Z\",\n \"price\": 1500,\n \"documentContentWordsChunked\": [\n {\n \"passage\": \"Facebook ad copy and image specs...\",\n \"embedding\": null\n }\n ]\n },\n {\n \"ticketId\": \"TCK-003\",\n \"title\": \"Quarterly Performance Report\",\n \"description\": \"Compile metrics and insights for Q3 marketing performance.\",\n \"status\": \"closed\",\n \"priority\": \"low\",\n \"category\": \"reporting\",\n \"assignee\": \"carla.lee\",\n \"createdAt\": \"2024-08-30T09:05:45Z\",\n \"price\": 0,\n \"documentContentWordsChunked\": [\n {\n \"passage\": \"Q3 performance data and analysis...\",\n \"embedding\": null\n }\n ]\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Show tickets\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, I will list the tickets for you.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"List documents\",\n \"dsl_type\": \"listing\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"match_all\": {}\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ],\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n }\n }\n }\n]\n\nUser Query: Show tickets\n\nRephrased Query: List all tickets\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"listing\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"match_all\": {}\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n}" } ]
{ "domain": "Marketing Campaigns", "data_type": "structured", "query_type": "listing", "pattern": "initial", "pattern_type": "listing_query", "size": 10, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: Ticket Management\n\nField Mappings:\n{\n \"properties\": {\n \"ticketId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"description\": {\n \"type\": \"text\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"priority\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"assignee\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"price\": {\n \"type\": \"float\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"ticketId\": \"TCK-1001\",\n \"title\": \"Network outage in building A\",\n \"description\": \"Users report loss of connectivity on floor 3.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"network\",\n \"assignee\": \"tech support\",\n \"createdAt\": \"2025-10-20T08:15:30Z\",\n \"price\": 0\n },\n {\n \"ticketId\": \"TCK-1002\",\n \"title\": \"Software license renewal\",\n \"description\": \"Renewal needed for accounting software.\",\n \"status\": \"closed\",\n \"priority\": \"medium\",\n \"category\": \"software\",\n \"assignee\": \"procurement\",\n \"createdAt\": \"2025-09-15T14:42:10Z\",\n \"price\": 1200\n },\n {\n \"ticketId\": \"TCK-1003\",\n \"title\": \"Printer malfunction on 2nd floor\",\n \"description\": \"Paper jam recurring every hour.\",\n \"status\": \"open\",\n \"priority\": \"low\",\n \"category\": \"hardware\",\n \"assignee\": \"facility team\",\n \"createdAt\": \"2025-10-22T11:05:45Z\",\n \"price\": 0\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Show open tickets\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Here are the open tickets...\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"List closed tickets\",\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": [\n {\n \"term\": {\n \"status\": \"closed\"\n }\n }\n ]\n }\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n }\n]\n\nUser Query: Show open high-priority tickets assigned to tech support\n\nRephrased Query: List open tickets with priority high assigned to tech support\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": [\n {\n \"term\": {\n \"status\": \"open\"\n }\n },\n {\n \"term\": {\n \"priority\": \"high\"\n }\n },\n {\n \"term\": {\n \"assignee\": \"tech support\"\n }\n }\n ]\n }\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n}" } ]
{ "domain": "Ticket Management", "data_type": "structured", "query_type": "listing_with_filters", "pattern": "initial", "pattern_type": "complex_query", "size": 10, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: Legal Documents\n\nField Mappings:\n{\n \"properties\": {\n \"documentId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"author\": {\n \"type\": \"keyword\"\n },\n \"department\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"fileType\": {\n \"type\": \"keyword\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"tags\": {\n \"type\": \"keyword\"\n },\n \"confidentialityLevel\": {\n \"type\": \"keyword\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"documentId\": \"DOC-001\",\n \"title\": \"Finance Policy 2024\",\n \"author\": \"Jane Smith\",\n \"department\": \"Finance\",\n \"createdAt\": \"2024-02-15T09:30:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"policy\",\n \"tags\": [\n \"budget\",\n \"compliance\"\n ],\n \"confidentialityLevel\": \"internal\"\n },\n {\n \"documentId\": \"DOC-002\",\n \"title\": \"IT Security Guidelines\",\n \"author\": \"John Doe\",\n \"department\": \"IT Security\",\n \"createdAt\": \"2023-11-01T14:00:00Z\",\n \"fileType\": \"docx\",\n \"status\": \"approved\",\n \"category\": \"guideline\",\n \"tags\": [\n \"encryption\",\n \"access control\"\n ],\n \"confidentialityLevel\": \"confidential\"\n },\n {\n \"documentId\": \"DOC-003\",\n \"title\": \"Remote Work Agreement\",\n \"author\": \"Emily Johnson\",\n \"department\": \"HR\",\n \"createdAt\": \"2024-01-20T08:45:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"draft\",\n \"category\": \"agreement\",\n \"tags\": [\n \"remote\",\n \"policy\"\n ],\n \"confidentialityLevel\": \"public\"\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Show approved policies from IT Security\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Here are the approved IT Security policies...\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"Show approved policies from IT Security\",\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": [\n {\n \"term\": {\n \"department\": \"IT Security\"\n }\n },\n {\n \"term\": {\n \"status\": \"approved\"\n }\n }\n ]\n }\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n }\n]\n\nUser Query: List PDFs from Finance department after 2024\n\nRephrased Query: List PDF documents where department is Finance and createdAt is on or after 2024-01-01\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": [\n {\n \"term\": {\n \"fileType\": \"pdf\"\n }\n },\n {\n \"term\": {\n \"department\": \"Finance\"\n }\n },\n {\n \"range\": {\n \"createdAt\": {\n \"gte\": \"2024-01-01\"\n }\n }\n }\n ]\n }\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n}" } ]
{ "domain": "Legal Documents", "data_type": "unstructured", "query_type": "listing_with_filters", "pattern": "initial", "pattern_type": "sorted_listing", "size": 10, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: HR Employee Records\n\nField Mappings:\n{\n \"properties\": {\n \"ticketId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"description\": {\n \"type\": \"text\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"priority\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"assignee\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"price\": {\n \"type\": \"float\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"ticketId\": \"TCK-001\",\n \"title\": \"Network latency issue\",\n \"description\": \"Users experiencing high latency on internal VPN.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"network\",\n \"assignee\": \"tech support\",\n \"createdAt\": \"2024-10-12T08:15:30Z\",\n \"price\": 0\n },\n {\n \"ticketId\": \"TCK-002\",\n \"title\": \"Payroll discrepancy\",\n \"description\": \"Incorrect salary amount for employee ID 4521.\",\n \"status\": \"resolved\",\n \"priority\": \"medium\",\n \"category\": \"finance\",\n \"assignee\": \"hr specialist\",\n \"createdAt\": \"2024-09-28T14:42:10Z\",\n \"price\": 0\n },\n {\n \"ticketId\": \"TCK-003\",\n \"title\": \"Access request for HR portal\",\n \"description\": \"New hire needs access to employee records.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"access\",\n \"assignee\": \"it admin\",\n \"createdAt\": \"2024-10-01T09:05:45Z\",\n \"price\": 0\n },\n {\n \"ticketId\": \"TCK-004\",\n \"title\": \"Office chair replacement\",\n \"description\": \"Ergonomic chair needed for employee with back pain.\",\n \"status\": \"in_progress\",\n \"priority\": \"low\",\n \"category\": \"facilities\",\n \"assignee\": \"facilities team\",\n \"createdAt\": \"2024-09-20T11:30:00Z\",\n \"price\": 250\n },\n {\n \"ticketId\": \"TCK-005\",\n \"title\": \"Email delivery failure\",\n \"description\": \"External emails bouncing back from domain example.com.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"network\",\n \"assignee\": \"tech support\",\n \"createdAt\": \"2024-10-10T16:22:18Z\",\n \"price\": 0\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Show open tickets\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Here are the open tickets in the system.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"Show open tickets\",\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": [\n {\n \"term\": {\n \"status\": \"open\"\n }\n }\n ]\n }\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n }\n]\n\nUser Query: List high-priority network tickets assigned to tech support\n\nRephrased Query: Retrieve tickets with status open, priority high, category network, and assignee tech support\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": [\n {\n \"term\": {\n \"status\": \"open\"\n }\n },\n {\n \"term\": {\n \"priority\": \"high\"\n }\n },\n {\n \"term\": {\n \"category\": \"network\"\n }\n },\n {\n \"term\": {\n \"assignee\": \"tech support\"\n }\n }\n ]\n }\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n}" } ]
{ "domain": "HR Employee Records", "data_type": "structured", "query_type": "listing_with_filters", "pattern": "initial", "pattern_type": "complex_query", "size": 10, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: Supplier Contracts\n\nField Mappings:\n{\n \"properties\": {\n \"ticketId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"description\": {\n \"type\": \"text\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"priority\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"assignee\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"price\": {\n \"type\": \"float\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"ticketId\": \"TCK-001\",\n \"title\": \"Contract renewal for Supplier A\",\n \"description\": \"Negotiation for renewal of the annual supply contract with Supplier A.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"contract\",\n \"assignee\": \"john.doe\",\n \"createdAt\": \"2024-09-01T10:15:00Z\",\n \"price\": 15000,\n \"documentContentWordsChunked\": []\n },\n {\n \"ticketId\": \"TCK-002\",\n \"title\": \"Closed contract for Supplier B\",\n \"description\": \"Completed contract for one-time purchase from Supplier B.\",\n \"status\": \"closed\",\n \"priority\": \"low\",\n \"category\": \"purchase\",\n \"assignee\": \"jane.smith\",\n \"createdAt\": \"2024-07-20T14:30:00Z\",\n \"price\": 8200.5,\n \"documentContentWordsChunked\": []\n },\n {\n \"ticketId\": \"TCK-003\",\n \"title\": \"Pending amendment for Supplier C\",\n \"description\": \"Amendment request pending approval for Supplier C's service agreement.\",\n \"status\": \"open\",\n \"priority\": \"medium\",\n \"category\": \"amendment\",\n \"assignee\": \"alice.wang\",\n \"createdAt\": \"2024-08-15T09:45:00Z\",\n \"price\": 4300,\n \"documentContentWordsChunked\": []\n }\n]\n\nChat History:\n[]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"List high-priority network tickets assigned to tech support\",\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": [\n {\n \"term\": {\n \"priority\": \"high\"\n }\n },\n {\n \"term\": {\n \"category\": \"network\"\n }\n },\n {\n \"term\": {\n \"assignee\": \"tech support\"\n }\n }\n ]\n }\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n }\n]\n\nUser Query: Show open tickets\n\nRephrased Query: List all tickets where status is open\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": [\n {\n \"term\": {\n \"status\": \"open\"\n }\n }\n ]\n }\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n}" } ]
{ "domain": "Supplier Contracts", "data_type": "structured", "query_type": "listing_with_filters", "pattern": "initial", "pattern_type": "categorical_listing", "size": 10, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: Inventory Items\n\nField Mappings:\n{\n \"properties\": {\n \"ticketId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"description\": {\n \"type\": \"text\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"priority\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"assignee\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"price\": {\n \"type\": \"float\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"ticketId\": \"TCK-1001\",\n \"title\": \"Router failure in Data Center\",\n \"description\": \"The main router in rack 12 is down, causing network outage.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"network\",\n \"assignee\": \"tech_support\",\n \"createdAt\": \"2025-10-20T08:15:30Z\",\n \"price\": 0,\n \"documentContentWordsChunked\": []\n },\n {\n \"ticketId\": \"TCK-1002\",\n \"title\": \"Laptop battery replacement\",\n \"description\": \"User reports rapid battery drain on laptop model X200.\",\n \"status\": \"closed\",\n \"priority\": \"low\",\n \"category\": \"hardware\",\n \"assignee\": \"field_engineer\",\n \"createdAt\": \"2025-09-15T14:42:10Z\",\n \"price\": 120.5,\n \"documentContentWordsChunked\": []\n },\n {\n \"ticketId\": \"TCK-1003\",\n \"title\": \"Software license renewal\",\n \"description\": \"Renew annual license for accounting software.\",\n \"status\": \"open\",\n \"priority\": \"medium\",\n \"category\": \"software\",\n \"assignee\": \"procurement\",\n \"createdAt\": \"2025-11-01T09:00:00Z\",\n \"price\": 2500,\n \"documentContentWordsChunked\": []\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Show 10 tickets\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Here is a sample DSL for listing 10 tickets.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"Show 10 tickets\",\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": []\n }\n }\n }\n }\n]\n\nUser Query: Show 52 open high-priority network tickets assigned to tech support\n\nRephrased Query: List 52 tickets where status is open, priority is high, category is network, and assignee is tech_support\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 52,\n \"from\": 0,\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": [\n {\n \"term\": {\n \"status\": \"open\"\n }\n },\n {\n \"term\": {\n \"priority\": \"high\"\n }\n },\n {\n \"term\": {\n \"category\": \"network\"\n }\n },\n {\n \"term\": {\n \"assignee\": \"tech_support\"\n }\n }\n ]\n }\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n}" } ]
{ "domain": "Inventory Items", "data_type": "structured", "query_type": "listing_with_filters", "pattern": "initial", "pattern_type": "sorted_listing", "size": 52, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: Research Papers\n\nField Mappings:\n{\n \"properties\": {\n \"documentId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"author\": {\n \"type\": \"text\"\n },\n \"department\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"fileType\": {\n \"type\": \"keyword\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"tags\": {\n \"type\": \"keyword\"\n },\n \"confidentialityLevel\": {\n \"type\": \"keyword\"\n },\n \"documentContentWords\": {\n \"type\": \"text\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"documentId\": \"RP-001\",\n \"title\": \"Secure Remote Work Policies\",\n \"author\": \"Dr. Alice Nguyen\",\n \"department\": \"IT Security\",\n \"createdAt\": \"2023-11-15T09:30:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"policy\",\n \"tags\": [\n \"security\",\n \"remote work\",\n \"policy\"\n ],\n \"confidentialityLevel\": \"internal\"\n },\n {\n \"documentId\": \"RP-002\",\n \"title\": \"Data Encryption Standards for 2024\",\n \"author\": \"Prof. Marco Silva\",\n \"department\": \"Data Science\",\n \"createdAt\": \"2024-02-20T14:12:00Z\",\n \"fileType\": \"docx\",\n \"status\": \"draft\",\n \"category\": \"technical\",\n \"tags\": [\n \"encryption\",\n \"standards\",\n \"2024\"\n ],\n \"confidentialityLevel\": \"confidential\"\n },\n {\n \"documentId\": \"RP-003\",\n \"title\": \"Annual Report on Cyber Threat Landscape\",\n \"author\": \"Dr. Priya Patel\",\n \"department\": \"Cybersecurity\",\n \"createdAt\": \"2024-07-01T08:00:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"report\",\n \"tags\": [\n \"threats\",\n \"annual\",\n \"cybersecurity\"\n ],\n \"confidentialityLevel\": \"public\"\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Can you list the latest security policies?\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, here are the most recent approved security policies...\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"Show tickets\",\n \"dsl_type\": \"hybrid_search\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"match_all\": {}\n }\n }\n }\n]\n\nUser Query: Show approved policies\n\nRephrased Query: List approved policy documents\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"hybrid_search\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"match_all\": {}\n }\n }\n}" } ]
{ "domain": "Research Papers", "data_type": "unstructured", "query_type": "hybrid_search", "pattern": "initial", "pattern_type": "categorical_listing", "size": 10, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: BlogPosts\n\nField Mappings:\n{\n \"properties\": {\n \"documentId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"author\": {\n \"type\": \"keyword\"\n },\n \"department\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"fileType\": {\n \"type\": \"keyword\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"tags\": {\n \"type\": \"keyword\"\n },\n \"confidentialityLevel\": {\n \"type\": \"keyword\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"documentId\": \"doc-001\",\n \"title\": \"Understanding Remote Work Policies\",\n \"author\": \"alice.smith\",\n \"department\": \"HR\",\n \"createdAt\": \"2024-02-15T09:30:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"policy\",\n \"tags\": [\n \"remote\",\n \"work\",\n \"policy\"\n ],\n \"confidentialityLevel\": \"public\"\n },\n {\n \"documentId\": \"doc-002\",\n \"title\": \"IT Security Guidelines\",\n \"author\": \"bob.johnson\",\n \"department\": \"IT Security\",\n \"createdAt\": \"2023-11-20T14:12:00Z\",\n \"fileType\": \"docx\",\n \"status\": \"approved\",\n \"category\": \"guideline\",\n \"tags\": [\n \"security\",\n \"access\",\n \"encryption\"\n ],\n \"confidentialityLevel\": \"internal\"\n },\n {\n \"documentId\": \"doc-003\",\n \"title\": \"Annual Financial Report 2024\",\n \"author\": \"carla.lee\",\n \"department\": \"Finance\",\n \"createdAt\": \"2024-08-01T08:00:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"draft\",\n \"category\": \"report\",\n \"tags\": [\n \"finance\",\n \"2024\",\n \"report\"\n ],\n \"confidentialityLevel\": \"confidential\"\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Can you list the latest blog posts about security?\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, I will retrieve the most recent security‑related posts.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"List documents\",\n \"dsl_type\": \"hybrid_search\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"match_all\": {}\n }\n }\n }\n]\n\nUser Query: Show tickets\n\nRephrased Query: Retrieve a list of tickets\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"hybrid_search\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"match_all\": {}\n }\n }\n}" } ]
{ "domain": "BlogPosts", "data_type": "unstructured", "query_type": "hybrid_search", "pattern": "initial", "pattern_type": "listing", "size": 10, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: Product Catalog\n\nField Mappings:\n{\n \"properties\": {\n \"productId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"description\": {\n \"type\": \"text\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"priority\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"assignee\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"price\": {\n \"type\": \"float\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"productId\": \"P1001\",\n \"title\": \"Wireless Noise‑Cancelling Headphones\",\n \"description\": \"Over‑ear headphones with active noise cancellation, 30‑hour battery life, and Bluetooth 5.2.\",\n \"status\": \"available\",\n \"priority\": \"high\",\n \"category\": \"electronics\",\n \"assignee\": \"inventory_team\",\n \"createdAt\": \"2024-09-12T08:15:30Z\",\n \"price\": 199.99,\n \"documentContentWordsChunked\": [\n {\n \"passage\": \"Wireless headphones with premium sound quality.\",\n \"embedding\": [\n 0,\n 0,\n 0\n ]\n }\n ]\n },\n {\n \"productId\": \"P1002\",\n \"title\": \"Ergonomic Office Chair\",\n \"description\": \"Adjustable lumbar support, breathable mesh back, and smooth‑rolling casters.\",\n \"status\": \"out_of_stock\",\n \"priority\": \"medium\",\n \"category\": \"furniture\",\n \"assignee\": \"sales_team\",\n \"createdAt\": \"2024-08-05T14:42:10Z\",\n \"price\": 349.5,\n \"documentContentWordsChunked\": [\n {\n \"passage\": \"Comfortable office chair for long working hours.\",\n \"embedding\": [\n 0,\n 0,\n 0\n ]\n }\n ]\n },\n {\n \"productId\": \"P1003\",\n \"title\": \"Smart Home Hub\",\n \"description\": \"Control lights, thermostats, and security cameras from a single app.\",\n \"status\": \"available\",\n \"priority\": \"low\",\n \"category\": \"smart_home\",\n \"assignee\": \"tech_support\",\n \"createdAt\": \"2024-10-01T09:00:00Z\",\n \"price\": 129,\n \"documentContentWordsChunked\": [\n {\n \"passage\": \"Central hub for all smart home devices.\",\n \"embedding\": [\n 0,\n 0,\n 0\n ]\n }\n ]\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Show tickets\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, retrieving the first 10 tickets for you.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"List documents\",\n \"dsl_type\": \"listing\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"match_all\": {}\n },\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n }\n]\n\nUser Query: Show tickets\n\nRephrased Query: List all tickets without any filters\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"listing\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"match_all\": {}\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n}" } ]
{ "domain": "Product Catalog", "data_type": "structured", "query_type": "listing", "pattern": "initial", "pattern_type": "listing", "size": 10, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: IT Support Tickets\n\nField Mappings:\n{\n \"properties\": {\n \"ticketId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"description\": {\n \"type\": \"text\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"priority\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"assignee\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"price\": {\n \"type\": \"float\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"ticketId\": \"TCK-1001\",\n \"title\": \"Network outage in Building A\",\n \"description\": \"Users report loss of connectivity on floor 3. Router rebooted but issue persists.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"network\",\n \"assignee\": \"tech_support\",\n \"createdAt\": \"2025-10-20T08:15:00Z\",\n \"price\": 0\n },\n {\n \"ticketId\": \"TCK-1002\",\n \"title\": \"Software license renewal\",\n \"description\": \"Need to renew Adobe Creative Cloud licenses for design team.\",\n \"status\": \"in_progress\",\n \"priority\": \"medium\",\n \"category\": \"software\",\n \"assignee\": \"procurement\",\n \"createdAt\": \"2025-09-30T14:42:00Z\",\n \"price\": 1200\n },\n {\n \"ticketId\": \"TCK-1003\",\n \"title\": \"Password reset for user John Doe\",\n \"description\": \"User unable to login to VPN after password change.\",\n \"status\": \"resolved\",\n \"priority\": \"low\",\n \"category\": \"access\",\n \"assignee\": \"help_desk\",\n \"createdAt\": \"2025-08-15T09:05:00Z\",\n \"price\": 0\n },\n {\n \"ticketId\": \"TCK-1004\",\n \"title\": \"Server CPU spikes\",\n \"description\": \"CPU usage >90% on DB server during peak hours.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"hardware\",\n \"assignee\": \"sys_admin\",\n \"createdAt\": \"2025-10-22T11:30:00Z\",\n \"price\": 0\n },\n {\n \"ticketId\": \"TCK-1005\",\n \"title\": \"Email delivery delay\",\n \"description\": \"Outgoing emails are delayed by up to 30 minutes.\",\n \"status\": \"in_progress\",\n \"priority\": \"medium\",\n \"category\": \"email\",\n \"assignee\": \"mail_admin\",\n \"createdAt\": \"2025-10-01T16:20:00Z\",\n \"price\": 0\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Can you show me the tickets that need immediate attention?\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, I will list the high‑priority tickets that are currently open.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"List all open tickets\",\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": [\n {\n \"term\": {\n \"status\": \"open\"\n }\n }\n ]\n }\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n }\n]\n\nUser Query: Show high priority network tickets assigned to tech support\n\nRephrased Query: List tickets where priority is high, category is network, and assignee is tech_support\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 10,\n \"from\": 30,\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": [\n {\n \"term\": {\n \"priority\": \"high\"\n }\n },\n {\n \"term\": {\n \"category\": \"network\"\n }\n },\n {\n \"term\": {\n \"assignee\": \"tech_support\"\n }\n },\n {\n \"term\": {\n \"status\": \"open\"\n }\n }\n ]\n }\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n}" } ]
{ "domain": "IT Support Tickets", "data_type": "structured", "query_type": "listing_with_filters", "pattern": "pagination", "pattern_type": "specific_page", "size": 10, "from": 30, "is_pagination": true }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: Ticket Management\n\nField Mappings:\n{\n \"properties\": {\n \"ticketId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"description\": {\n \"type\": \"text\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"priority\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"assignee\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"price\": {\n \"type\": \"float\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"ticketId\": \"TCK-1001\",\n \"title\": \"Network latency issue\",\n \"description\": \"Users experience high latency on the corporate VPN.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"network\",\n \"assignee\": \"tech support\",\n \"createdAt\": \"2025-10-20T08:15:30Z\",\n \"price\": 0\n },\n {\n \"ticketId\": \"TCK-1002\",\n \"title\": \"Server disk space low\",\n \"description\": \"The primary database server is running out of disk space.\",\n \"status\": \"in_progress\",\n \"priority\": \"medium\",\n \"category\": \"infrastructure\",\n \"assignee\": \"sys admin\",\n \"createdAt\": \"2025-10-18T14:42:10Z\",\n \"price\": 0\n },\n {\n \"ticketId\": \"TCK-1003\",\n \"title\": \"Email delivery failure\",\n \"description\": \"Outgoing emails are bouncing with error 550.\",\n \"status\": \"resolved\",\n \"priority\": \"low\",\n \"category\": \"email\",\n \"assignee\": \"support team\",\n \"createdAt\": \"2025-09-30T11:05:45Z\",\n \"price\": 0\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Show open tickets\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Here are the currently open tickets...\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"Show open tickets\",\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": [\n {\n \"term\": {\n \"status\": \"open\"\n }\n }\n ]\n }\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n }\n]\n\nUser Query: List high-priority network tickets assigned to tech support\n\nRephrased Query: Show tickets with priority high, category network, and assignee tech support\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": [\n {\n \"term\": {\n \"priority\": \"high\"\n }\n },\n {\n \"term\": {\n \"category\": \"network\"\n }\n },\n {\n \"term\": {\n \"assignee\": \"tech support\"\n }\n }\n ]\n }\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n}" } ]
{ "domain": "Ticket Management", "data_type": "structured", "query_type": "listing_with_filters", "pattern": "initial", "pattern_type": "sorted_listing", "size": 10, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: Supplier Contracts\n\nField Mappings:\n{\n \"properties\": {\n \"contractId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"description\": {\n \"type\": \"text\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"priority\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"assignee\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"price\": {\n \"type\": \"float\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"contractId\": \"C-1001\",\n \"title\": \"Annual Supply Agreement - Electronics\",\n \"description\": \"Contract for supplying electronic components to XYZ Corp for the fiscal year 2024.\",\n \"status\": \"active\",\n \"priority\": \"high\",\n \"category\": \"electronics\",\n \"assignee\": \"john.doe\",\n \"createdAt\": \"2024-01-15T09:30:00Z\",\n \"price\": 125000\n },\n {\n \"contractId\": \"C-1002\",\n \"title\": \"Quarterly Raw Materials Supply\",\n \"description\": \"Supply of raw materials for manufacturing plastic parts.\",\n \"status\": \"pending\",\n \"priority\": \"medium\",\n \"category\": \"raw_materials\",\n \"assignee\": \"jane.smith\",\n \"createdAt\": \"2024-02-20T14:45:00Z\",\n \"price\": 75000\n },\n {\n \"contractId\": \"C-1003\",\n \"title\": \"One‑Time Office Furniture Purchase\",\n \"description\": \"Purchase of office chairs and desks for new headquarters.\",\n \"status\": \"completed\",\n \"priority\": \"low\",\n \"category\": \"furniture\",\n \"assignee\": \"alice.wang\",\n \"createdAt\": \"2023-12-05T11:10:00Z\",\n \"price\": 32000\n }\n]\n\nChat History:\n[]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"list 10 contracts\",\n \"dsl_type\": \"listing\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"match_all\": {}\n }\n }\n }\n]\n\nUser Query: Show me 17 supplier contracts\n\nRephrased Query: list 17 supplier contracts without filters\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"listing\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 17,\n \"from\": 0,\n \"query\": {\n \"match_all\": {}\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n}" } ]
{ "domain": "Supplier Contracts", "data_type": "structured", "query_type": "listing", "pattern": "initial", "pattern_type": "categorical_listing", "size": 17, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: Supplier Contracts\n\nField Mappings:\n{\n \"properties\": {\n \"ticketId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"description\": {\n \"type\": \"text\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"priority\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"assignee\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"price\": {\n \"type\": \"float\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"ticketId\": \"SC-1001\",\n \"title\": \"Network Infrastructure Upgrade Contract\",\n \"description\": \"Contract for upgrading the supplier's network infrastructure across all data centers.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"network\",\n \"assignee\": \"tech support\",\n \"createdAt\": \"2024-09-12T08:15:30Z\",\n \"price\": 125000,\n \"documentContentWordsChunked\": [\n {\n \"passage\": \"The supplier shall provide all necessary hardware and services...\",\n \"embedding\": [\n 0,\n 0,\n 0\n ]\n }\n ]\n },\n {\n \"ticketId\": \"SC-1002\",\n \"title\": \"Cloud Service Level Agreement\",\n \"description\": \"SLA for cloud compute resources with guaranteed uptime.\",\n \"status\": \"closed\",\n \"priority\": \"medium\",\n \"category\": \"cloud\",\n \"assignee\": \"legal team\",\n \"createdAt\": \"2024-07-05T14:42:10Z\",\n \"price\": 85000,\n \"documentContentWordsChunked\": [\n {\n \"passage\": \"The provider guarantees 99.9% availability...\",\n \"embedding\": [\n 0,\n 0,\n 0\n ]\n }\n ]\n },\n {\n \"ticketId\": \"SC-1003\",\n \"title\": \"Software Maintenance Contract\",\n \"description\": \"Annual maintenance for enterprise software suite.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"software\",\n \"assignee\": \"tech support\",\n \"createdAt\": \"2024-10-01T11:20:45Z\",\n \"price\": 47000,\n \"documentContentWordsChunked\": [\n {\n \"passage\": \"Maintenance includes bug fixes, security patches, and feature updates...\",\n \"embedding\": [\n 0,\n 0,\n 0\n ]\n }\n ]\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Show me 49 open high-priority network tickets assigned to tech support.\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, I’ll build a listing query that returns 49 open tickets with high priority, category network, and assignee tech support.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"List 10 tickets\",\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": []\n }\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n }\n]\n\nUser Query: List 49 high-priority network tickets that are open and assigned to tech support\n\nRephrased Query: Retrieve 49 open tickets with high priority, category network, assigned to tech support\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 49,\n \"from\": 0,\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": [\n {\n \"term\": {\n \"status\": \"open\"\n }\n },\n {\n \"term\": {\n \"priority\": \"high\"\n }\n },\n {\n \"term\": {\n \"category\": \"network\"\n }\n },\n {\n \"term\": {\n \"assignee\": \"tech support\"\n }\n }\n ]\n }\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n}" } ]
{ "domain": "Supplier Contracts", "data_type": "structured", "query_type": "listing_with_filters", "pattern": "initial", "pattern_type": "categorical_listing", "size": 49, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: Academic Articles\n\nField Mappings:\n{\n \"properties\": {\n \"documentId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"author\": {\n \"type\": \"keyword\"\n },\n \"department\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"fileType\": {\n \"type\": \"keyword\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"tags\": {\n \"type\": \"keyword\"\n },\n \"confidentialityLevel\": {\n \"type\": \"keyword\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"documentId\": \"DOC-001\",\n \"title\": \"Advances in Quantum Computing\",\n \"author\": \"Dr. Alice Smith\",\n \"department\": \"Physics\",\n \"createdAt\": \"2023-05-12T09:30:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"research\",\n \"tags\": [\n \"quantum\",\n \"computing\",\n \"technology\"\n ],\n \"confidentialityLevel\": \"public\"\n },\n {\n \"documentId\": \"DOC-002\",\n \"title\": \"Remote Work Security Policies\",\n \"author\": \"John Doe\",\n \"department\": \"IT Security\",\n \"createdAt\": \"2024-01-20T14:15:00Z\",\n \"fileType\": \"docx\",\n \"status\": \"approved\",\n \"category\": \"policy\",\n \"tags\": [\n \"remote\",\n \"security\",\n \"policy\"\n ],\n \"confidentialityLevel\": \"internal\"\n },\n {\n \"documentId\": \"DOC-003\",\n \"title\": \"Financial Forecast 2025\",\n \"author\": \"Maria Garcia\",\n \"department\": \"Finance\",\n \"createdAt\": \"2024-03-08T11:00:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"draft\",\n \"category\": \"report\",\n \"tags\": [\n \"forecast\",\n \"2025\",\n \"finance\"\n ],\n \"confidentialityLevel\": \"confidential\"\n },\n {\n \"documentId\": \"DOC-004\",\n \"title\": \"Machine Learning in Healthcare\",\n \"author\": \"Dr. Kevin Lee\",\n \"department\": \"Biomedical Engineering\",\n \"createdAt\": \"2022-11-30T08:45:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"research\",\n \"tags\": [\n \"machine learning\",\n \"healthcare\",\n \"AI\"\n ],\n \"confidentialityLevel\": \"public\"\n },\n {\n \"documentId\": \"DOC-005\",\n \"title\": \"Campus Sustainability Initiative\",\n \"author\": \"Emily Zhang\",\n \"department\": \"Environmental Studies\",\n \"createdAt\": \"2023-09-15T10:20:00Z\",\n \"fileType\": \"docx\",\n \"status\": \"approved\",\n \"category\": \"initiative\",\n \"tags\": [\n \"sustainability\",\n \"campus\",\n \"green\"\n ],\n \"confidentialityLevel\": \"public\"\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Can you list the latest research papers on AI?\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, here are a few recent AI research papers from our repository...\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"Show me 10 recent finance reports\",\n \"dsl_type\": \"simple_search\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"match_all\": {}\n }\n }\n }\n]\n\nUser Query: Show me 63 approved policies from IT Security\n\nRephrased Query: Retrieve 63 approved policy documents belonging to the IT Security department\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"hybrid_search\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 63,\n \"from\": 189,\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": [\n {\n \"term\": {\n \"status\": \"approved\"\n }\n },\n {\n \"term\": {\n \"department\": \"IT Security\"\n }\n }\n ]\n }\n }\n }\n}" } ]
{ "domain": "Academic Articles", "data_type": "unstructured", "query_type": "hybrid_search", "pattern": "pagination", "pattern_type": "next_page", "size": 63, "from": 189, "is_pagination": true }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: Technical Manuals\n\nField Mappings:\n{\n \"properties\": {\n \"documentId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"author\": {\n \"type\": \"keyword\"\n },\n \"department\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"fileType\": {\n \"type\": \"keyword\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"tags\": {\n \"type\": \"keyword\"\n },\n \"confidentialityLevel\": {\n \"type\": \"keyword\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"documentId\": \"TM-001\",\n \"title\": \"IT Security Policy - Access Control\",\n \"author\": \"alice.smith\",\n \"department\": \"IT Security\",\n \"createdAt\": \"2023-11-15T08:30:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"policy\",\n \"tags\": [\n \"access\",\n \"control\",\n \"security\"\n ],\n \"confidentialityLevel\": \"internal\"\n },\n {\n \"documentId\": \"TM-002\",\n \"title\": \"Finance Department Remote Work Guidelines\",\n \"author\": \"bob.johnson\",\n \"department\": \"Finance\",\n \"createdAt\": \"2024-02-10T12:00:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"draft\",\n \"category\": \"guideline\",\n \"tags\": [\n \"remote\",\n \"work\",\n \"finance\"\n ],\n \"confidentialityLevel\": \"confidential\"\n },\n {\n \"documentId\": \"TM-003\",\n \"title\": \"HR Confidentiality Level Definitions\",\n \"author\": \"carol.lee\",\n \"department\": \"Human Resources\",\n \"createdAt\": \"2022-07-01T09:15:00Z\",\n \"fileType\": \"docx\",\n \"status\": \"approved\",\n \"category\": \"reference\",\n \"tags\": [\n \"confidentiality\",\n \"levels\"\n ],\n \"confidentialityLevel\": \"public\"\n },\n {\n \"documentId\": \"TM-004\",\n \"title\": \"IT Security Policy - Incident Response\",\n \"author\": \"david.kim\",\n \"department\": \"IT Security\",\n \"createdAt\": \"2024-01-20T14:45:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"policy\",\n \"tags\": [\n \"incident\",\n \"response\",\n \"security\"\n ],\n \"confidentialityLevel\": \"internal\"\n },\n {\n \"documentId\": \"TM-005\",\n \"title\": \"Engineering Department Code Review Checklist\",\n \"author\": \"emma.wong\",\n \"department\": \"Engineering\",\n \"createdAt\": \"2023-09-05T11:20:00Z\",\n \"fileType\": \"xlsx\",\n \"status\": \"approved\",\n \"category\": \"process\",\n \"tags\": [\n \"code\",\n \"review\",\n \"checklist\"\n ],\n \"confidentialityLevel\": \"internal\"\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Can you show me the latest security policies?\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, here are the most recent approved security policy documents.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"What are the security policies?\",\n \"dsl_type\": \"semantic_search\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"knn\": {\n \"field\": \"documentContentWordsChunked.embedding\",\n \"query_vector\": \"[...]\",\n \"k\": 10,\n \"num_candidates\": 100\n }\n },\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n }\n }\n }\n]\n\nUser Query: Show approved policies from IT Security\n\nRephrased Query: List approved policy documents in the IT Security department\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"hybrid_search_with_filters\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"hybrid\": {\n \"query\": \"approved policy\",\n \"fields\": [\n \"title\",\n \"tags\",\n \"category\"\n ],\n \"filter\": {\n \"bool\": {\n \"must\": [\n {\n \"term\": {\n \"status\": \"approved\"\n }\n },\n {\n \"term\": {\n \"department\": \"IT Security\"\n }\n }\n ]\n }\n }\n }\n }\n }\n}" } ]
{ "domain": "Technical Manuals", "data_type": "unstructured", "query_type": "hybrid_search_with_filters", "pattern": "initial", "pattern_type": "listing_with_filters", "size": 10, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: Legal Documents\n\nField Mappings:\n{\n \"properties\": {\n \"documentId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"author\": {\n \"type\": \"keyword\"\n },\n \"department\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"fileType\": {\n \"type\": \"keyword\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"tags\": {\n \"type\": \"keyword\"\n },\n \"confidentialityLevel\": {\n \"type\": \"keyword\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"documentId\": \"DOC-001\",\n \"title\": \"IT Security Policy – Access Control\",\n \"author\": \"Jane Smith\",\n \"department\": \"IT Security\",\n \"createdAt\": \"2023-11-15T09:30:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"policy\",\n \"tags\": [\n \"access\",\n \"control\",\n \"authentication\"\n ],\n \"confidentialityLevel\": \"internal\"\n },\n {\n \"documentId\": \"DOC-002\",\n \"title\": \"Remote Work Guidelines\",\n \"author\": \"Michael Lee\",\n \"department\": \"Human Resources\",\n \"createdAt\": \"2024-02-01T14:00:00Z\",\n \"fileType\": \"docx\",\n \"status\": \"approved\",\n \"category\": \"guideline\",\n \"tags\": [\n \"remote\",\n \"work\",\n \"policy\"\n ],\n \"confidentialityLevel\": \"public\"\n },\n {\n \"documentId\": \"DOC-003\",\n \"title\": \"Data Retention Schedule 2024\",\n \"author\": \"Laura Chen\",\n \"department\": \"Legal\",\n \"createdAt\": \"2024-01-20T11:45:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"draft\",\n \"category\": \"schedule\",\n \"tags\": [\n \"data\",\n \"retention\",\n \"compliance\"\n ],\n \"confidentialityLevel\": \"confidential\"\n },\n {\n \"documentId\": \"DOC-004\",\n \"title\": \"Finance Department Expense Policy\",\n \"author\": \"Robert Patel\",\n \"department\": \"Finance\",\n \"createdAt\": \"2023-09-10T08:15:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"policy\",\n \"tags\": [\n \"expense\",\n \"reimbursement\",\n \"finance\"\n ],\n \"confidentialityLevel\": \"internal\"\n },\n {\n \"documentId\": \"DOC-005\",\n \"title\": \"Company Code of Conduct\",\n \"author\": \"Emily Davis\",\n \"department\": \"Corporate Affairs\",\n \"createdAt\": \"2022-05-05T10:00:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"policy\",\n \"tags\": [\n \"ethics\",\n \"behavior\",\n \"compliance\"\n ],\n \"confidentialityLevel\": \"public\"\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Can you show me the latest security policies?\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, here are the most recent security policy documents.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"Show 10 recent policies\",\n \"dsl_type\": \"hybrid_search\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"query\": {\n \"bool\": {\n \"should\": [\n {\n \"match_all\": {}\n },\n {\n \"knn\": {\n \"field\": \"documentContentWordsChunked.embedding\",\n \"query_vector\": [\n 0\n ],\n \"k\": 10,\n \"num_candidates\": 100\n }\n }\n ]\n }\n }\n }\n }\n]\n\nUser Query: Show $20 approved policies from IT Security\n\nRephrased Query: Retrieve the first 20 approved policy documents in the IT Security department\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"hybrid_search\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 20,\n \"from\": 20,\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match\": {\n \"status\": \"approved\"\n }\n },\n {\n \"match\": {\n \"department\": \"IT Security\"\n }\n }\n ],\n \"should\": [\n {\n \"match_all\": {}\n },\n {\n \"knn\": {\n \"field\": \"documentContentWordsChunked.embedding\",\n \"query_vector\": [\n 0\n ],\n \"k\": 20,\n \"num_candidates\": 200\n }\n }\n ]\n }\n }\n }\n}" } ]
{ "domain": "Legal Documents", "data_type": "unstructured", "query_type": "hybrid_search", "pattern": "pagination", "pattern_type": "specific_page", "size": 20, "from": 20, "is_pagination": true }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: Product Reviews\n\nField Mappings:\n{\n \"properties\": {\n \"documentId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"author\": {\n \"type\": \"keyword\"\n },\n \"department\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"fileType\": {\n \"type\": \"keyword\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"tags\": {\n \"type\": \"keyword\"\n },\n \"confidentialityLevel\": {\n \"type\": \"keyword\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"documentId\": \"doc-001\",\n \"title\": \"Quarterly Security Policy Update\",\n \"author\": \"alice.smith\",\n \"department\": \"IT Security\",\n \"createdAt\": \"2024-03-15T09:30:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"policy\",\n \"tags\": [\n \"security\",\n \"policy\",\n \"quarterly\"\n ],\n \"confidentialityLevel\": \"internal\"\n },\n {\n \"documentId\": \"doc-002\",\n \"title\": \"Finance Department Expense Guidelines\",\n \"author\": \"bob.jones\",\n \"department\": \"Finance\",\n \"createdAt\": \"2024-01-10T14:20:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"draft\",\n \"category\": \"guideline\",\n \"tags\": [\n \"finance\",\n \"expenses\"\n ],\n \"confidentialityLevel\": \"confidential\"\n },\n {\n \"documentId\": \"doc-003\",\n \"title\": \"Remote Work Best Practices\",\n \"author\": \"carol.lee\",\n \"department\": \"Human Resources\",\n \"createdAt\": \"2023-11-05T08:00:00Z\",\n \"fileType\": \"docx\",\n \"status\": \"approved\",\n \"category\": \"procedure\",\n \"tags\": [\n \"remote\",\n \"work\",\n \"policy\"\n ],\n \"confidentialityLevel\": \"public\"\n }\n]\n\nChat History:\n[]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"List PDFs from Finance department after 2024\",\n \"dsl_type\": \"hybrid_search_with_filters\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"query\": {\n \"hybrid\": {\n \"vector\": [],\n \"fields\": [\n \"documentContentWordsChunked.passage\"\n ],\n \"filter\": {\n \"bool\": {\n \"must\": [\n {\n \"term\": {\n \"department\": \"Finance\"\n }\n },\n {\n \"term\": {\n \"fileType\": \"pdf\"\n }\n },\n {\n \"range\": {\n \"createdAt\": {\n \"gt\": \"2024-01-01\"\n }\n }\n }\n ]\n }\n }\n }\n }\n }\n }\n]\n\nUser Query: Show approved policies from IT Security\n\nRephrased Query: List approved policy documents in the IT Security department\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"hybrid_search_with_filters\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"hybrid\": {\n \"vector\": [],\n \"fields\": [\n \"documentContentWordsChunked.passage\"\n ],\n \"filter\": {\n \"bool\": {\n \"must\": [\n {\n \"term\": {\n \"status\": \"approved\"\n }\n },\n {\n \"term\": {\n \"department\": \"IT Security\"\n }\n },\n {\n \"term\": {\n \"category\": \"policy\"\n }\n }\n ]\n }\n }\n }\n }\n }\n}" } ]
{ "domain": "Product Reviews", "data_type": "unstructured", "query_type": "hybrid_search_with_filters", "pattern": "initial", "pattern_type": "keyword_search", "size": 10, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: Product Reviews\n\nField Mappings:\n{\n \"properties\": {\n \"documentId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"author\": {\n \"type\": \"keyword\"\n },\n \"department\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"fileType\": {\n \"type\": \"keyword\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"tags\": {\n \"type\": \"keyword\"\n },\n \"confidentialityLevel\": {\n \"type\": \"keyword\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"documentId\": \"doc-001\",\n \"title\": \"Annual Security Policy Overview\",\n \"author\": \"alice.smith\",\n \"department\": \"IT Security\",\n \"createdAt\": \"2024-02-15T09:30:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"policy\",\n \"tags\": [\n \"security\",\n \"policy\",\n \"annual\"\n ],\n \"confidentialityLevel\": \"internal\"\n },\n {\n \"documentId\": \"doc-002\",\n \"title\": \"Remote Work Guidelines\",\n \"author\": \"bob.johnson\",\n \"department\": \"Human Resources\",\n \"createdAt\": \"2023-11-01T14:00:00Z\",\n \"fileType\": \"docx\",\n \"status\": \"draft\",\n \"category\": \"guideline\",\n \"tags\": [\n \"remote\",\n \"work\",\n \"policy\"\n ],\n \"confidentialityLevel\": \"public\"\n },\n {\n \"documentId\": \"doc-003\",\n \"title\": \"Finance Department Q4 Report\",\n \"author\": \"carol.lee\",\n \"department\": \"Finance\",\n \"createdAt\": \"2024-01-20T11:45:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"report\",\n \"tags\": [\n \"finance\",\n \"Q4\",\n \"report\"\n ],\n \"confidentialityLevel\": \"confidential\"\n },\n {\n \"documentId\": \"doc-004\",\n \"title\": \"Product Review: SmartHome Hub\",\n \"author\": \"dave.kim\",\n \"department\": \"Product Management\",\n \"createdAt\": \"2024-03-05T08:20:00Z\",\n \"fileType\": \"txt\",\n \"status\": \"approved\",\n \"category\": \"review\",\n \"tags\": [\n \"smart home\",\n \"hub\",\n \"review\"\n ],\n \"confidentialityLevel\": \"public\"\n },\n {\n \"documentId\": \"doc-005\",\n \"title\": \"IT Security Incident Response Plan\",\n \"author\": \"eve.martinez\",\n \"department\": \"IT Security\",\n \"createdAt\": \"2024-04-10T16:10:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"plan\",\n \"tags\": [\n \"incident\",\n \"response\",\n \"security\"\n ],\n \"confidentialityLevel\": \"internal\"\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Can you show me the latest security policies?\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, here are the most recent approved security policy documents.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"List PDFs from Finance department after 2024\",\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"term\": {\n \"department\": \"Finance\"\n }\n },\n {\n \"term\": {\n \"fileType\": \"pdf\"\n }\n },\n {\n \"range\": {\n \"createdAt\": {\n \"gt\": \"2024-01-01T00:00:00Z\"\n }\n }\n }\n ]\n }\n }\n }\n }\n]\n\nUser Query: Show approved policies from IT Security\n\nRephrased Query: List approved documents in the IT Security department\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"hybrid_search_with_filters\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"hybrid\": {\n \"text\": {\n \"field\": \"title\",\n \"query\": \"approved policies\"\n },\n \"vector\": {\n \"field\": \"documentContentWordsChunked.embedding\",\n \"query_vector\": \"<embedding_placeholder>\",\n \"k\": 10\n },\n \"filter\": {\n \"bool\": {\n \"must\": [\n {\n \"term\": {\n \"status\": \"approved\"\n }\n },\n {\n \"term\": {\n \"department\": \"IT Security\"\n }\n }\n ]\n }\n }\n }\n }\n }\n}" } ]
{ "domain": "Product Reviews", "data_type": "unstructured", "query_type": "hybrid_search_with_filters", "pattern": "initial", "pattern_type": "sorted_listing", "size": 10, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: Legal Documents\n\nField Mappings:\n{\n \"properties\": {\n \"documentId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"author\": {\n \"type\": \"keyword\"\n },\n \"department\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"fileType\": {\n \"type\": \"keyword\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"tags\": {\n \"type\": \"keyword\"\n },\n \"confidentialityLevel\": {\n \"type\": \"keyword\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"documentId\": \"DOC-001\",\n \"title\": \"IT Security Approved Policy – Data Encryption\",\n \"author\": \"alice.smith\",\n \"department\": \"IT Security\",\n \"createdAt\": \"2024-02-15T09:30:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"policy\",\n \"tags\": [\n \"encryption\",\n \"data-protection\"\n ],\n \"confidentialityLevel\": \"internal\"\n },\n {\n \"documentId\": \"DOC-002\",\n \"title\": \"Finance Department Approved Policy – Expense Reimbursement\",\n \"author\": \"bob.johnson\",\n \"department\": \"Finance\",\n \"createdAt\": \"2023-11-01T14:20:00Z\",\n \"fileType\": \"docx\",\n \"status\": \"approved\",\n \"category\": \"policy\",\n \"tags\": [\n \"expenses\",\n \"reimbursement\"\n ],\n \"confidentialityLevel\": \"confidential\"\n },\n {\n \"documentId\": \"DOC-003\",\n \"title\": \"HR Draft Policy – Remote Work Guidelines\",\n \"author\": \"carol.lee\",\n \"department\": \"Human Resources\",\n \"createdAt\": \"2024-07-10T08:00:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"draft\",\n \"category\": \"policy\",\n \"tags\": [\n \"remote-work\",\n \"guidelines\"\n ],\n \"confidentialityLevel\": \"public\"\n },\n {\n \"documentId\": \"DOC-004\",\n \"title\": \"Legal Approved Policy – Contract Review Process\",\n \"author\": \"david.kim\",\n \"department\": \"Legal\",\n \"createdAt\": \"2023-05-22T11:45:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"policy\",\n \"tags\": [\n \"contracts\",\n \"review\"\n ],\n \"confidentialityLevel\": \"restricted\"\n },\n {\n \"documentId\": \"DOC-005\",\n \"title\": \"IT Security Draft Policy – Incident Response\",\n \"author\": \"eve.wang\",\n \"department\": \"IT Security\",\n \"createdAt\": \"2024-09-03T16:10:00Z\",\n \"fileType\": \"docx\",\n \"status\": \"draft\",\n \"category\": \"policy\",\n \"tags\": [\n \"incident-response\",\n \"security\"\n ],\n \"confidentialityLevel\": \"internal\"\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Can you list the approved policies for the IT Security department?\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, I will retrieve the approved policies from the IT Security department.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"Show approved policies from IT Security\",\n \"dsl_type\": \"hybrid_search_with_filters\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"query\": {\n \"hybrid\": {\n \"text\": {\n \"field\": \"title\",\n \"query\": \"approved policies\"\n },\n \"filter\": {\n \"bool\": {\n \"must\": [\n {\n \"term\": {\n \"status\": \"approved\"\n }\n },\n {\n \"term\": {\n \"department\": \"IT Security\"\n }\n }\n ]\n }\n }\n }\n }\n }\n }\n]\n\nUser Query: Show approved policies from IT Security\n\nRephrased Query: List approved policies in the IT Security department\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"hybrid_search_with_filters\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"hybrid\": {\n \"text\": {\n \"field\": \"title\",\n \"query\": \"approved policies\"\n },\n \"filter\": {\n \"bool\": {\n \"must\": [\n {\n \"term\": {\n \"status\": \"approved\"\n }\n },\n {\n \"term\": {\n \"department\": \"IT Security\"\n }\n }\n ]\n }\n }\n }\n }\n }\n}" } ]
{ "domain": "Legal Documents", "data_type": "unstructured", "query_type": "hybrid_search_with_filters", "pattern": "initial", "pattern_type": "listing_with_filters", "size": 10, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: Inventory Items\n\nField Mappings:\n{\n \"properties\": {\n \"productId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"description\": {\n \"type\": \"text\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"priority\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"assignee\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"price\": {\n \"type\": \"float\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"productId\": \"P-1001\",\n \"title\": \"Router Model X200\",\n \"description\": \"High-performance router for enterprise networks.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"network\",\n \"assignee\": \"tech_support\",\n \"createdAt\": \"2025-10-20T08:15:30Z\",\n \"price\": 299.99\n },\n {\n \"productId\": \"P-1002\",\n \"title\": \"Switch Model S350\",\n \"description\": \"24-port gigabit switch with PoE support.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"network\",\n \"assignee\": \"tech_support\",\n \"createdAt\": \"2025-10-18T14:42:10Z\",\n \"price\": 149.49\n },\n {\n \"productId\": \"P-1003\",\n \"title\": \"Firewall Pro F500\",\n \"description\": \"Advanced firewall with intrusion detection.\",\n \"status\": \"closed\",\n \"priority\": \"medium\",\n \"category\": \"security\",\n \"assignee\": \"security_team\",\n \"createdAt\": \"2025-09-30T11:05:00Z\",\n \"price\": 499\n },\n {\n \"productId\": \"P-1004\",\n \"title\": \"Server Rack 42U\",\n \"description\": \"Standard 42U rack for data center equipment.\",\n \"status\": \"open\",\n \"priority\": \"low\",\n \"category\": \"hardware\",\n \"assignee\": \"logistics\",\n \"createdAt\": \"2025-10-01T09:20:45Z\",\n \"price\": 799.99\n },\n {\n \"productId\": \"P-1005\",\n \"title\": \"Wireless Access Point AP300\",\n \"description\": \"Dual-band Wi-Fi 6 access point.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"network\",\n \"assignee\": \"tech_support\",\n \"createdAt\": \"2025-10-22T16:30:20Z\",\n \"price\": 129.95\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Show me the latest tickets.\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, here are the most recent tickets.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"List 10 tickets\",\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": []\n }\n }\n }\n }\n]\n\nUser Query: Show 16 high-priority network tickets assigned to tech support\n\nRephrased Query: List 16 tickets where status is open, priority is high, category is network, and assignee is tech_support\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 16,\n \"from\": 48,\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": [\n {\n \"term\": {\n \"status\": \"open\"\n }\n },\n {\n \"term\": {\n \"priority\": \"high\"\n }\n },\n {\n \"term\": {\n \"category\": \"network\"\n }\n },\n {\n \"term\": {\n \"assignee\": \"tech_support\"\n }\n }\n ]\n }\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n}" } ]
{ "domain": "Inventory Items", "data_type": "structured", "query_type": "listing_with_filters", "pattern": "pagination", "pattern_type": "next_page", "size": 16, "from": 48, "is_pagination": true }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: Technical Manuals\n\nField Mappings:\n{\n \"properties\": {\n \"documentId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"author\": {\n \"type\": \"keyword\"\n },\n \"department\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"fileType\": {\n \"type\": \"keyword\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"tags\": {\n \"type\": \"keyword\"\n },\n \"confidentialityLevel\": {\n \"type\": \"keyword\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"documentId\": \"TM-001\",\n \"title\": \"Network Security Policy\",\n \"author\": \"Alice Johnson\",\n \"department\": \"IT Security\",\n \"createdAt\": \"2023-05-12T08:30:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"policy\",\n \"tags\": [\n \"security\",\n \"network\",\n \"policy\"\n ],\n \"confidentialityLevel\": \"internal\"\n },\n {\n \"documentId\": \"TM-002\",\n \"title\": \"Remote Work Guidelines\",\n \"author\": \"Bob Lee\",\n \"department\": \"Human Resources\",\n \"createdAt\": \"2024-01-20T14:15:00Z\",\n \"fileType\": \"docx\",\n \"status\": \"draft\",\n \"category\": \"guideline\",\n \"tags\": [\n \"remote\",\n \"work\",\n \"policy\"\n ],\n \"confidentialityLevel\": \"public\"\n },\n {\n \"documentId\": \"TM-003\",\n \"title\": \"Data Encryption Standards\",\n \"author\": \"Carol Smith\",\n \"department\": \"IT Security\",\n \"createdAt\": \"2022-11-03T10:00:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"standard\",\n \"tags\": [\n \"encryption\",\n \"data\",\n \"security\"\n ],\n \"confidentialityLevel\": \"confidential\"\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Show tickets\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, retrieving the first 10 tickets for you.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"Show tickets\",\n \"dsl_type\": \"hybrid_search\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"match_all\": {}\n }\n }\n }\n]\n\nUser Query: Show tickets\n\nRephrased Query: List all tickets\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"hybrid_search\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"match_all\": {}\n }\n }\n}" } ]
{ "domain": "Technical Manuals", "data_type": "unstructured", "query_type": "hybrid_search", "pattern": "refinement", "pattern_type": "add_filter", "size": 10, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: Product Catalog Tickets\n\nField Mappings:\n{\n \"properties\": {\n \"ticketId\": {\n \"type\": \"keyword\"\n },\n \"productId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"description\": {\n \"type\": \"text\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"priority\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"assignee\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"price\": {\n \"type\": \"float\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"ticketId\": \"TCK-001\",\n \"productId\": \"PRD-1001\",\n \"title\": \"Network latency issue\",\n \"description\": \"Customers experiencing high latency on the corporate VPN.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"network\",\n \"assignee\": \"tech support\",\n \"createdAt\": \"2025-10-20T08:15:30Z\",\n \"price\": 0\n },\n {\n \"ticketId\": \"TCK-002\",\n \"productId\": \"PRD-1002\",\n \"title\": \"Billing discrepancy\",\n \"description\": \"Invoice shows incorrect amount for last month.\",\n \"status\": \"resolved\",\n \"priority\": \"medium\",\n \"category\": \"account\",\n \"assignee\": \"billing team\",\n \"createdAt\": \"2025-09-15T14:42:10Z\",\n \"price\": 0\n },\n {\n \"ticketId\": \"TCK-003\",\n \"productId\": \"PRD-1003\",\n \"title\": \"Software installation failure\",\n \"description\": \"Error code 0x80070005 during installation on Windows 10.\",\n \"status\": \"in_progress\",\n \"priority\": \"high\",\n \"category\": \"software\",\n \"assignee\": \"dev ops\",\n \"createdAt\": \"2025-11-01T11:05:45Z\",\n \"price\": 0\n },\n {\n \"ticketId\": \"TCK-004\",\n \"productId\": \"PRD-1004\",\n \"title\": \"Product price update request\",\n \"description\": \"Need to update price for seasonal promotion.\",\n \"status\": \"closed\",\n \"priority\": \"low\",\n \"category\": \"pricing\",\n \"assignee\": \"product manager\",\n \"createdAt\": \"2025-08-22T09:30:00Z\",\n \"price\": 199.99\n },\n {\n \"ticketId\": \"TCK-005\",\n \"productId\": \"PRD-1005\",\n \"title\": \"Hardware warranty claim\",\n \"description\": \"Customer submitted claim for defective router.\",\n \"status\": \"open\",\n \"priority\": \"medium\",\n \"category\": \"hardware\",\n \"assignee\": \"support desk\",\n \"createdAt\": \"2025-10-05T16:20:12Z\",\n \"price\": 0\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Can you list the tickets I need to work on today?\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, I can help with that. Do you have any specific filters like status or priority?\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"Show all tickets\",\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": []\n }\n },\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n }\n]\n\nUser Query: Show open high-priority network tickets assigned to tech support\n\nRephrased Query: List tickets where status is open, priority is high, category is network, and assignee is tech support\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": [\n {\n \"term\": {\n \"status\": \"open\"\n }\n },\n {\n \"term\": {\n \"priority\": \"high\"\n }\n },\n {\n \"term\": {\n \"category\": \"network\"\n }\n },\n {\n \"match_phrase\": {\n \"assignee\": \"tech support\"\n }\n }\n ]\n }\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n}" } ]
{ "domain": "Product Catalog Tickets", "data_type": "structured", "query_type": "listing_with_filters", "pattern": "initial", "pattern_type": "complex_query", "size": 10, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: Customer Support Tickets\n\nField Mappings:\n{\n \"properties\": {\n \"documentId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"author\": {\n \"type\": \"keyword\"\n },\n \"department\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"fileType\": {\n \"type\": \"keyword\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"tags\": {\n \"type\": \"keyword\"\n },\n \"confidentialityLevel\": {\n \"type\": \"keyword\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"documentId\": \"TCK-001\",\n \"title\": \"IT Security Approved Policy – Password Management\",\n \"author\": \"alice.smith\",\n \"department\": \"IT Security\",\n \"createdAt\": \"2024-02-15T09:30:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"policy\",\n \"tags\": [\n \"password\",\n \"security\",\n \"compliance\"\n ],\n \"confidentialityLevel\": \"internal\"\n },\n {\n \"documentId\": \"TCK-002\",\n \"title\": \"IT Security Approved Policy – Remote Work Guidelines\",\n \"author\": \"bob.jones\",\n \"department\": \"IT Security\",\n \"createdAt\": \"2024-03-10T14:12:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"policy\",\n \"tags\": [\n \"remote\",\n \"work\",\n \"security\"\n ],\n \"confidentialityLevel\": \"internal\"\n },\n {\n \"documentId\": \"TCK-003\",\n \"title\": \"Finance Department Quarterly Report Q1 2024\",\n \"author\": \"carol.lee\",\n \"department\": \"Finance\",\n \"createdAt\": \"2024-04-01T08:00:00Z\",\n \"fileType\": \"xlsx\",\n \"status\": \"draft\",\n \"category\": \"report\",\n \"tags\": [\n \"quarterly\",\n \"finance\"\n ],\n \"confidentialityLevel\": \"confidential\"\n },\n {\n \"documentId\": \"TCK-004\",\n \"title\": \"HR Policy – Employee Onboarding\",\n \"author\": \"dave.kumar\",\n \"department\": \"Human Resources\",\n \"createdAt\": \"2023-12-20T11:45:00Z\",\n \"fileType\": \"docx\",\n \"status\": \"approved\",\n \"category\": \"policy\",\n \"tags\": [\n \"onboarding\",\n \"hr\"\n ],\n \"confidentialityLevel\": \"internal\"\n },\n {\n \"documentId\": \"TCK-005\",\n \"title\": \"IT Security Approved Policy – Data Encryption Standards\",\n \"author\": \"eve.wang\",\n \"department\": \"IT Security\",\n \"createdAt\": \"2024-01-05T10:20:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"policy\",\n \"tags\": [\n \"encryption\",\n \"data\",\n \"security\"\n ],\n \"confidentialityLevel\": \"internal\"\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Can you list the latest security policies?\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, here are the most recent approved policies from the IT Security department.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"Show 10 recent approved policies\",\n \"dsl_type\": \"hybrid_search_with_filters\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"query\": {\n \"hybrid\": {\n \"text\": \"approved policies\",\n \"vector\": {\n \"field\": \"documentContentWordsChunked.embedding\",\n \"query_vector\": [\n 0,\n 0,\n 0\n ],\n \"k\": 10\n },\n \"filter\": {\n \"bool\": {\n \"must\": [\n {\n \"term\": {\n \"status\": \"approved\"\n }\n },\n {\n \"term\": {\n \"department\": \"IT Security\"\n }\n }\n ]\n }\n }\n }\n }\n }\n }\n]\n\nUser Query: Show 22 approved policies from IT Security department\n\nRephrased Query: Retrieve 22 documents where status is approved and department is IT Security\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"hybrid_search_with_filters\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 22,\n \"from\": 0,\n \"query\": {\n \"hybrid\": {\n \"text\": \"approved policies\",\n \"vector\": {\n \"field\": \"documentContentWordsChunked.embedding\",\n \"query_vector\": [\n 0,\n 0,\n 0\n ],\n \"k\": 22\n },\n \"filter\": {\n \"bool\": {\n \"must\": [\n {\n \"term\": {\n \"status\": \"approved\"\n }\n },\n {\n \"term\": {\n \"department\": \"IT Security\"\n }\n }\n ]\n }\n }\n }\n }\n }\n}" } ]
{ "domain": "Customer Support Tickets", "data_type": "unstructured", "query_type": "hybrid_search_with_filters", "pattern": "initial", "pattern_type": "sorted_listing", "size": 22, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: Research Papers\n\nField Mappings:\n{\n \"properties\": {\n \"documentId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"author\": {\n \"type\": \"keyword\"\n },\n \"department\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"fileType\": {\n \"type\": \"keyword\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"tags\": {\n \"type\": \"keyword\"\n },\n \"confidentialityLevel\": {\n \"type\": \"keyword\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"documentId\": \"RP-001\",\n \"title\": \"Secure Cloud Computing Practices\",\n \"author\": \"Dr. Alice Smith\",\n \"department\": \"IT Security\",\n \"createdAt\": \"2024-02-15T10:30:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"security\",\n \"tags\": [\n \"cloud\",\n \"encryption\",\n \"access control\"\n ],\n \"confidentialityLevel\": \"internal\"\n },\n {\n \"documentId\": \"RP-002\",\n \"title\": \"Financial Forecasting Models 2025\",\n \"author\": \"John Doe\",\n \"department\": \"Finance\",\n \"createdAt\": \"2024-06-01T08:00:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"draft\",\n \"category\": \"finance\",\n \"tags\": [\n \"forecasting\",\n \"machine learning\"\n ],\n \"confidentialityLevel\": \"confidential\"\n },\n {\n \"documentId\": \"RP-003\",\n \"title\": \"Remote Work Policy Overview\",\n \"author\": \"Emily Zhang\",\n \"department\": \"Human Resources\",\n \"createdAt\": \"2023-11-20T14:45:00Z\",\n \"fileType\": \"docx\",\n \"status\": \"approved\",\n \"category\": \"policy\",\n \"tags\": [\n \"remote work\",\n \"guidelines\"\n ],\n \"confidentialityLevel\": \"public\"\n },\n {\n \"documentId\": \"RP-004\",\n \"title\": \"Data Privacy Regulations Summary\",\n \"author\": \"Dr. Michael Lee\",\n \"department\": \"Legal\",\n \"createdAt\": \"2024-03-10T12:00:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"compliance\",\n \"tags\": [\n \"GDPR\",\n \"privacy\",\n \"regulation\"\n ],\n \"confidentialityLevel\": \"restricted\"\n },\n {\n \"documentId\": \"RP-005\",\n \"title\": \"AI Ethics in Research\",\n \"author\": \"Sara Patel\",\n \"department\": \"Research\",\n \"createdAt\": \"2024-01-05T09:20:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"ethics\",\n \"tags\": [\n \"AI\",\n \"ethics\",\n \"responsibility\"\n ],\n \"confidentialityLevel\": \"internal\"\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Show approved policies from IT Security\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Here are the approved policies from the IT Security department...\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"List PDFs from Finance department after 2024\",\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": [\n {\n \"term\": {\n \"fileType\": \"pdf\"\n }\n },\n {\n \"term\": {\n \"department\": \"Finance\"\n }\n },\n {\n \"range\": {\n \"createdAt\": {\n \"gt\": \"2024-01-01\"\n }\n }\n }\n ]\n }\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n }\n]\n\nUser Query: List PDFs from Finance department after 2024\n\nRephrased Query: Show PDF documents where department is Finance and createdAt is after 2024-01-01\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": [\n {\n \"term\": {\n \"fileType\": \"pdf\"\n }\n },\n {\n \"term\": {\n \"department\": \"Finance\"\n }\n },\n {\n \"range\": {\n \"createdAt\": {\n \"gt\": \"2024-01-01\"\n }\n }\n }\n ]\n }\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n}" } ]
{ "domain": "Research Papers", "data_type": "unstructured", "query_type": "listing_with_filters", "pattern": "initial", "pattern_type": "keyword_search", "size": 10, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: Supplier Contracts\n\nField Mappings:\n{\n \"properties\": {\n \"ticketId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"description\": {\n \"type\": \"text\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"priority\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"assignee\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"price\": {\n \"type\": \"float\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"ticketId\": \"SC-001\",\n \"title\": \"Annual Supplier Agreement Renewal\",\n \"description\": \"Renewal of the annual contract with Supplier A for raw materials.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"network\",\n \"assignee\": \"tech_support\",\n \"createdAt\": \"2025-10-20T08:15:30Z\",\n \"price\": 125000\n },\n {\n \"ticketId\": \"SC-002\",\n \"title\": \"Price Adjustment Request\",\n \"description\": \"Supplier B requests a price increase due to market changes.\",\n \"status\": \"closed\",\n \"priority\": \"medium\",\n \"category\": \"finance\",\n \"assignee\": \"finance_team\",\n \"createdAt\": \"2025-09-12T14:42:10Z\",\n \"price\": 85000\n },\n {\n \"ticketId\": \"SC-003\",\n \"title\": \"Contract Termination Notice\",\n \"description\": \"Supplier C has issued a notice to terminate the contract effective next quarter.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"network\",\n \"assignee\": \"tech_support\",\n \"createdAt\": \"2025-11-01T11:05:45Z\",\n \"price\": 0\n }\n]\n\nChat History:\n[]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"List all tickets\",\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": []\n }\n },\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n }\n]\n\nUser Query: Show open high-priority network tickets assigned to tech support\n\nRephrased Query: List open tickets with high priority in the network category assigned to tech support\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": [\n {\n \"term\": {\n \"status\": \"open\"\n }\n },\n {\n \"term\": {\n \"priority\": \"high\"\n }\n },\n {\n \"term\": {\n \"category\": \"network\"\n }\n },\n {\n \"term\": {\n \"assignee\": \"tech_support\"\n }\n }\n ]\n }\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n}" } ]
{ "domain": "Supplier Contracts", "data_type": "structured", "query_type": "listing_with_filters", "pattern": "initial", "pattern_type": "categorical_listing", "size": 10, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: BlogPosts\n\nField Mappings:\n{\n \"properties\": {\n \"documentId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"author\": {\n \"type\": \"keyword\"\n },\n \"department\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"fileType\": {\n \"type\": \"keyword\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"tags\": {\n \"type\": \"keyword\"\n },\n \"confidentialityLevel\": {\n \"type\": \"keyword\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"documentId\": \"doc-001\",\n \"title\": \"Understanding Remote Work Policies\",\n \"author\": \"alice.smith\",\n \"department\": \"HR\",\n \"createdAt\": \"2024-02-15T09:30:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"policy\",\n \"tags\": [\n \"remote\",\n \"work\",\n \"policy\"\n ],\n \"confidentialityLevel\": \"public\"\n },\n {\n \"documentId\": \"doc-002\",\n \"title\": \"Cybersecurity Best Practices for 2024\",\n \"author\": \"bob.johnson\",\n \"department\": \"IT Security\",\n \"createdAt\": \"2024-01-10T14:20:00Z\",\n \"fileType\": \"docx\",\n \"status\": \"approved\",\n \"category\": \"guideline\",\n \"tags\": [\n \"security\",\n \"cybersecurity\",\n \"best practices\"\n ],\n \"confidentialityLevel\": \"internal\"\n },\n {\n \"documentId\": \"doc-003\",\n \"title\": \"Annual Financial Report Q1 2024\",\n \"author\": \"carol.lee\",\n \"department\": \"Finance\",\n \"createdAt\": \"2024-04-05T11:00:00Z\",\n \"fileType\": \"xlsx\",\n \"status\": \"draft\",\n \"category\": \"report\",\n \"tags\": [\n \"finance\",\n \"Q1\",\n \"2024\"\n ],\n \"confidentialityLevel\": \"confidential\"\n },\n {\n \"documentId\": \"doc-004\",\n \"title\": \"Company Blog: Innovations in AI\",\n \"author\": \"dave.kumar\",\n \"department\": \"Marketing\",\n \"createdAt\": \"2024-03-22T08:45:00Z\",\n \"fileType\": \"html\",\n \"status\": \"published\",\n \"category\": \"blog\",\n \"tags\": [\n \"AI\",\n \"innovation\",\n \"technology\"\n ],\n \"confidentialityLevel\": \"public\"\n },\n {\n \"documentId\": \"doc-005\",\n \"title\": \"Employee Handbook 2024\",\n \"author\": \"emma.wilson\",\n \"department\": \"HR\",\n \"createdAt\": \"2024-01-01T00:00:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"handbook\",\n \"tags\": [\n \"employee\",\n \"handbook\",\n \"policy\"\n ],\n \"confidentialityLevel\": \"public\"\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Show me the latest blog posts.\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, I will retrieve the most recent blog entries for you.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"List all approved policies\",\n \"dsl_type\": \"hybrid_search\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": [\n {\n \"term\": {\n \"status\": \"approved\"\n }\n }\n ]\n }\n }\n }\n }\n]\n\nUser Query: Show me the latest blog posts\n\nRephrased Query: Retrieve recent blog posts without any filters\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"hybrid_search\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 10,\n \"from\": 20,\n \"query\": {\n \"bool\": {\n \"should\": [\n {\n \"match_all\": {}\n },\n {\n \"knn\": {\n \"documentContentWordsChunked.embedding\": {\n \"vector\": [\n 0,\n 0,\n 0,\n \"...\"\n ],\n \"k\": 10\n }\n }\n }\n ],\n \"minimum_should_match\": 1\n }\n }\n }\n}" } ]
{ "domain": "BlogPosts", "data_type": "unstructured", "query_type": "hybrid_search", "pattern": "pagination", "pattern_type": "next_page", "size": 10, "from": 20, "is_pagination": true }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: Marketing Campaigns\n\nField Mappings:\n{\n \"properties\": {\n \"ticketId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"description\": {\n \"type\": \"text\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"priority\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"assignee\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"price\": {\n \"type\": \"float\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"ticketId\": \"MC-001\",\n \"title\": \"Spring Launch Email Blast\",\n \"description\": \"Prepare and send email campaign for Spring product line.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"email\",\n \"assignee\": \"alice.smith\",\n \"createdAt\": \"2024-03-01T09:15:00Z\",\n \"price\": 0,\n \"documentContentWordsChunked\": [\n {\n \"passage\": \"Spring collection features vibrant colors and new styles.\",\n \"embedding\": [\n 0,\n 0,\n 0\n ]\n }\n ]\n },\n {\n \"ticketId\": \"MC-002\",\n \"title\": \"Summer Social Media Ads\",\n \"description\": \"Design and schedule Instagram and Facebook ads for summer promotion.\",\n \"status\": \"in_progress\",\n \"priority\": \"medium\",\n \"category\": \"social_media\",\n \"assignee\": \"bob.jones\",\n \"createdAt\": \"2024-04-10T14:30:00Z\",\n \"price\": 1500,\n \"documentContentWordsChunked\": [\n {\n \"passage\": \"Target audience: 18-35, interests: travel, outdoor activities.\",\n \"embedding\": [\n 0,\n 0,\n 0\n ]\n }\n ]\n },\n {\n \"ticketId\": \"MC-003\",\n \"title\": \"Fall Webinar Series\",\n \"description\": \"Organize a series of webinars to showcase new product features.\",\n \"status\": \"closed\",\n \"priority\": \"low\",\n \"category\": \"webinar\",\n \"assignee\": \"carla.lee\",\n \"createdAt\": \"2024-09-05T11:00:00Z\",\n \"price\": 0,\n \"documentContentWordsChunked\": [\n {\n \"passage\": \"Webinar topics include integration, analytics, and user onboarding.\",\n \"embedding\": [\n 0,\n 0,\n 0\n ]\n }\n ]\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Show me 32 marketing tickets\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, I will generate a listing query that returns 32 results.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"list 10 tickets\",\n \"dsl_type\": \"listing\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"match_all\": {}\n }\n }\n }\n]\n\nUser Query: Show me 32 marketing tickets\n\nRephrased Query: list 32 marketing tickets without any filters\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"listing\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 32,\n \"from\": 0,\n \"query\": {\n \"match_all\": {}\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n}" } ]
{ "domain": "Marketing Campaigns", "data_type": "structured", "query_type": "listing", "pattern": "initial", "pattern_type": "categorical_listing", "size": 32, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: Medical Records\n\nField Mappings:\n{\n \"properties\": {\n \"documentId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"author\": {\n \"type\": \"keyword\"\n },\n \"department\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"fileType\": {\n \"type\": \"keyword\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"tags\": {\n \"type\": \"keyword\"\n },\n \"confidentialityLevel\": {\n \"type\": \"keyword\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"documentId\": \"MR-001\",\n \"title\": \"IT Security Policy – Access Control\",\n \"author\": \"Jane Doe\",\n \"department\": \"IT Security\",\n \"createdAt\": \"2023-11-15T09:30:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"policy\",\n \"tags\": [\n \"access\",\n \"control\",\n \"security\"\n ],\n \"confidentialityLevel\": \"high\"\n },\n {\n \"documentId\": \"MR-002\",\n \"title\": \"Remote Work Guidelines\",\n \"author\": \"John Smith\",\n \"department\": \"Human Resources\",\n \"createdAt\": \"2024-02-01T14:00:00Z\",\n \"fileType\": \"docx\",\n \"status\": \"approved\",\n \"category\": \"guideline\",\n \"tags\": [\n \"remote\",\n \"work\",\n \"policy\"\n ],\n \"confidentialityLevel\": \"medium\"\n },\n {\n \"documentId\": \"MR-003\",\n \"title\": \"Patient Data Confidentiality Agreement\",\n \"author\": \"Emily Clark\",\n \"department\": \"Legal\",\n \"createdAt\": \"2022-07-20T11:45:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"agreement\",\n \"tags\": [\n \"patient\",\n \"confidentiality\",\n \"legal\"\n ],\n \"confidentialityLevel\": \"high\"\n },\n {\n \"documentId\": \"MR-004\",\n \"title\": \"IT Security Policy – Incident Response\",\n \"author\": \"Michael Lee\",\n \"department\": \"IT Security\",\n \"createdAt\": \"2023-09-10T08:20:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"policy\",\n \"tags\": [\n \"incident\",\n \"response\",\n \"security\"\n ],\n \"confidentialityLevel\": \"high\"\n },\n {\n \"documentId\": \"MR-005\",\n \"title\": \"Annual Compliance Report 2024\",\n \"author\": \"Sarah Patel\",\n \"department\": \"Compliance\",\n \"createdAt\": \"2024-03-15T10:10:00Z\",\n \"fileType\": \"xlsx\",\n \"status\": \"approved\",\n \"category\": \"report\",\n \"tags\": [\n \"compliance\",\n \"annual\",\n \"2024\"\n ],\n \"confidentialityLevel\": \"medium\"\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Show 47 approved policies from IT Security\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, I will retrieve the 47 approved policy documents from the IT Security department.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"List 10 recent policies\",\n \"dsl_type\": \"hybrid_search\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"match_all\": {}\n }\n }\n }\n]\n\nUser Query: Show 47 approved policies from IT Security\n\nRephrased Query: Retrieve 47 approved policy documents from the IT Security department\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"hybrid_search\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 47,\n \"from\": 0,\n \"query\": {\n \"match_all\": {}\n }\n }\n}" } ]
{ "domain": "Medical Records", "data_type": "unstructured", "query_type": "hybrid_search", "pattern": "initial", "pattern_type": "sorted_listing", "size": 47, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: Product Catalog\n\nField Mappings:\n{\n \"properties\": {\n \"productId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"description\": {\n \"type\": \"text\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"priority\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"assignee\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"price\": {\n \"type\": \"float\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"productId\": \"P1001\",\n \"title\": \"Wireless Mouse\",\n \"description\": \"Ergonomic wireless mouse with adjustable DPI.\",\n \"status\": \"available\",\n \"priority\": \"low\",\n \"category\": \"electronics\",\n \"assignee\": \"inventory_team\",\n \"createdAt\": \"2024-09-12T08:15:30Z\",\n \"price\": 29.99,\n \"documentContentWordsChunked\": []\n },\n {\n \"productId\": \"P1002\",\n \"title\": \"Gaming Laptop\",\n \"description\": \"High-performance laptop with RTX graphics and 16GB RAM.\",\n \"status\": \"out_of_stock\",\n \"priority\": \"high\",\n \"category\": \"computers\",\n \"assignee\": \"sales_team\",\n \"createdAt\": \"2024-08-05T14:22:10Z\",\n \"price\": 1499,\n \"documentContentWordsChunked\": []\n },\n {\n \"productId\": \"P1003\",\n \"title\": \"Bluetooth Headphones\",\n \"description\": \"Noise-cancelling over-ear headphones with 20h battery life.\",\n \"status\": \"available\",\n \"priority\": \"medium\",\n \"category\": \"audio\",\n \"assignee\": \"support_team\",\n \"createdAt\": \"2024-07-20T10:05:45Z\",\n \"price\": 89.5,\n \"documentContentWordsChunked\": []\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Show tickets\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, retrieving the latest tickets for you.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"Show tickets\",\n \"dsl_type\": \"listing\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"match_all\": {}\n },\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n }\n]\n\nUser Query: Show tickets\n\nRephrased Query: List all tickets without any filters\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"listing\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"match_all\": {}\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n}" } ]
{ "domain": "Product Catalog", "data_type": "structured", "query_type": "listing", "pattern": "initial", "pattern_type": "filtered_search", "size": 10, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: Project Management Tasks\n\nField Mappings:\n{\n \"properties\": {\n \"ticketId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"description\": {\n \"type\": \"text\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"priority\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"assignee\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"price\": {\n \"type\": \"float\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"ticketId\": \"TCK-001\",\n \"title\": \"Network outage in building A\",\n \"description\": \"Investigate and resolve the network connectivity issue affecting floor 3.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"network\",\n \"assignee\": \"tech support\",\n \"createdAt\": \"2025-10-20T08:15:00Z\",\n \"price\": 0\n },\n {\n \"ticketId\": \"TCK-002\",\n \"title\": \"Update project budget\",\n \"description\": \"Adjust the budget for Q4 after new resource allocation.\",\n \"status\": \"in_progress\",\n \"priority\": \"medium\",\n \"category\": \"finance\",\n \"assignee\": \"project manager\",\n \"createdAt\": \"2025-09-15T11:30:00Z\",\n \"price\": 0\n },\n {\n \"ticketId\": \"TCK-003\",\n \"title\": \"Design review for new UI\",\n \"description\": \"Conduct a design review meeting with the UI/UX team.\",\n \"status\": \"resolved\",\n \"priority\": \"low\",\n \"category\": \"design\",\n \"assignee\": \"lead designer\",\n \"createdAt\": \"2025-08-05T14:45:00Z\",\n \"price\": 0\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Show tickets\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Here are the latest tickets from your project management index.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"Show tickets\",\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": []\n }\n },\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n }\n]\n\nUser Query: List high-priority network tickets assigned to tech support\n\nRephrased Query: Retrieve open tickets with high priority in the network category assigned to the tech support team\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": [\n {\n \"term\": {\n \"status\": \"open\"\n }\n },\n {\n \"term\": {\n \"priority\": \"high\"\n }\n },\n {\n \"term\": {\n \"category\": \"network\"\n }\n },\n {\n \"term\": {\n \"assignee\": \"tech support\"\n }\n }\n ]\n }\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n}" } ]
{ "domain": "Project Management Tasks", "data_type": "structured", "query_type": "listing_with_filters", "pattern": "initial", "pattern_type": "complex_query", "size": 10, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: Inventory Items\n\nField Mappings:\n{\n \"properties\": {\n \"ticketId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"description\": {\n \"type\": \"text\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"priority\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"assignee\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"price\": {\n \"type\": \"float\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"ticketId\": \"INV-1001\",\n \"title\": \"Router Replacement\",\n \"description\": \"Replace faulty router in data center rack 12.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"network\",\n \"assignee\": \"tech support\",\n \"createdAt\": \"2025-10-20T08:15:30Z\",\n \"price\": 250\n },\n {\n \"ticketId\": \"INV-1002\",\n \"title\": \"Laptop Procurement\",\n \"description\": \"Order 15 new laptops for the sales team.\",\n \"status\": \"closed\",\n \"priority\": \"medium\",\n \"category\": \"hardware\",\n \"assignee\": \"procurement\",\n \"createdAt\": \"2025-09-15T11:42:10Z\",\n \"price\": 18000\n },\n {\n \"ticketId\": \"INV-1003\",\n \"title\": \"Software License Renewal\",\n \"description\": \"Renew annual licenses for the design software suite.\",\n \"status\": \"open\",\n \"priority\": \"low\",\n \"category\": \"software\",\n \"assignee\": \"it admin\",\n \"createdAt\": \"2025-10-05T14:07:55Z\",\n \"price\": 7200\n },\n {\n \"ticketId\": \"INV-1004\",\n \"title\": \"Server Disk Upgrade\",\n \"description\": \"Add 2TB SSD to server S-02 for increased storage capacity.\",\n \"status\": \"in_progress\",\n \"priority\": \"high\",\n \"category\": \"hardware\",\n \"assignee\": \"tech support\",\n \"createdAt\": \"2025-10-12T09:30:00Z\",\n \"price\": 400\n },\n {\n \"ticketId\": \"INV-1005\",\n \"title\": \"Network Security Audit\",\n \"description\": \"Perform quarterly security audit on all network devices.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"network\",\n \"assignee\": \"security team\",\n \"createdAt\": \"2025-10-01T10:20:45Z\",\n \"price\": 1500\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Show open tickets\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Here are the open tickets in the inventory system...\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"List all tickets\",\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": []\n }\n },\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n }\n]\n\nUser Query: List high-priority network tickets assigned to tech support\n\nRephrased Query: Show open tickets with priority high, category network, and assignee tech support\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 10,\n \"from\": 10,\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": [\n {\n \"term\": {\n \"status\": \"open\"\n }\n },\n {\n \"term\": {\n \"priority\": \"high\"\n }\n },\n {\n \"term\": {\n \"category\": \"network\"\n }\n },\n {\n \"term\": {\n \"assignee\": \"tech support\"\n }\n }\n ]\n }\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n}" } ]
{ "domain": "Inventory Items", "data_type": "structured", "query_type": "listing_with_filters", "pattern": "pagination", "pattern_type": "previous_page", "size": 10, "from": 10, "is_pagination": true }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: Financial Transactions\n\nField Mappings:\n{\n \"properties\": {\n \"ticketId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"description\": {\n \"type\": \"text\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"priority\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"assignee\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"price\": {\n \"type\": \"double\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"ticketId\": \"TXN-1001\",\n \"title\": \"Failed Wire Transfer\",\n \"description\": \"Customer reported that a wire transfer of $12,500 to account 987654 failed with error code 502.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"wire_transfer\",\n \"assignee\": \"john.doe\",\n \"createdAt\": \"2025-10-30T08:15:27Z\",\n \"price\": 12500\n },\n {\n \"ticketId\": \"TXN-1002\",\n \"title\": \"Duplicate Credit Card Charge\",\n \"description\": \"Two identical charges of $199.99 appeared on the customer's statement for invoice INV-54321.\",\n \"status\": \"in_progress\",\n \"priority\": \"medium\",\n \"category\": \"card_payment\",\n \"assignee\": \"jane.smith\",\n \"createdAt\": \"2025-10-28T14:42:10Z\",\n \"price\": 199.99\n },\n {\n \"ticketId\": \"TXN-1003\",\n \"title\": \"Request for Transaction History Export\",\n \"description\": \"Client needs CSV export of all transactions between 2024-01-01 and 2024-12-31 for audit purposes.\",\n \"status\": \"resolved\",\n \"priority\": \"low\",\n \"category\": \"reporting\",\n \"assignee\": \"alice.wang\",\n \"createdAt\": \"2025-10-20T09:05:44Z\",\n \"price\": 0\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Can you list all open tickets?\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, fetching the first 10 open tickets for you.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"List open tickets\",\n \"dsl_type\": \"listing\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"match_all\": {}\n },\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n }\n]\n\nUser Query: Show tickets\n\nRephrased Query: List all tickets without any filter\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"listing\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"match_all\": {}\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n}" } ]
{ "domain": "Financial Transactions", "data_type": "structured", "query_type": "listing", "pattern": "initial", "pattern_type": "complex_query", "size": 10, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: customer_support_tickets\n\nField Mappings:\n{\n \"properties\": {\n \"documentId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"author\": {\n \"type\": \"keyword\"\n },\n \"department\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"fileType\": {\n \"type\": \"keyword\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"tags\": {\n \"type\": \"keyword\"\n },\n \"confidentialityLevel\": {\n \"type\": \"keyword\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"documentId\": \"TCKT-001\",\n \"title\": \"Password Reset Request\",\n \"author\": \"jdoe\",\n \"department\": \"IT Support\",\n \"createdAt\": \"2024-09-12T08:15:00Z\",\n \"fileType\": \"txt\",\n \"status\": \"open\",\n \"category\": \"authentication\",\n \"tags\": [\n \"password\",\n \"reset\"\n ],\n \"confidentialityLevel\": \"internal\"\n },\n {\n \"documentId\": \"TCKT-002\",\n \"title\": \"VPN Access Denied\",\n \"author\": \"asmith\",\n \"department\": \"Network\",\n \"createdAt\": \"2024-08-30T14:42:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"closed\",\n \"category\": \"network\",\n \"tags\": [\n \"vpn\",\n \"access\"\n ],\n \"confidentialityLevel\": \"confidential\"\n },\n {\n \"documentId\": \"TCKT-003\",\n \"title\": \"Security Policy Update\",\n \"author\": \"mlee\",\n \"department\": \"IT Security\",\n \"createdAt\": \"2024-07-20T10:00:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"policy\",\n \"tags\": [\n \"security\",\n \"policy\",\n \"update\"\n ],\n \"confidentialityLevel\": \"public\"\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Can you show me the latest tickets from the Network department?\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, here are the most recent tickets from Network.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"List PDFs from Finance department after 2024\",\n \"dsl_type\": \"hybrid_search_with_filters\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"query\": {\n \"hybrid\": {\n \"query\": {\n \"match_all\": {}\n },\n \"filter\": {\n \"bool\": {\n \"must\": [\n {\n \"term\": {\n \"department\": \"Finance\"\n }\n },\n {\n \"term\": {\n \"fileType\": \"pdf\"\n }\n },\n {\n \"range\": {\n \"createdAt\": {\n \"gt\": \"2024-01-01T00:00:00Z\"\n }\n }\n }\n ]\n }\n }\n }\n }\n }\n }\n]\n\nUser Query: Show approved policies from IT Security\n\nRephrased Query: List approved policy documents from the IT Security department\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"hybrid_search_with_filters\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"hybrid\": {\n \"query\": {\n \"match_all\": {}\n },\n \"filter\": {\n \"bool\": {\n \"must\": [\n {\n \"term\": {\n \"status\": \"approved\"\n }\n },\n {\n \"term\": {\n \"department\": \"IT Security\"\n }\n },\n {\n \"term\": {\n \"category\": \"policy\"\n }\n }\n ]\n }\n }\n }\n }\n }\n}" } ]
{ "domain": "customer_support_tickets", "data_type": "unstructured", "query_type": "hybrid_search_with_filters", "pattern": "initial", "pattern_type": "sorted_listing", "size": 10, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: Project Management Tasks\n\nField Mappings:\n{\n \"properties\": {\n \"ticketId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"description\": {\n \"type\": \"text\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"priority\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"assignee\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"price\": {\n \"type\": \"float\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"ticketId\": \"TCK-001\",\n \"title\": \"Network latency issue\",\n \"description\": \"Investigate and resolve high latency in the corporate network.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"network\",\n \"assignee\": \"tech_support\",\n \"createdAt\": \"2025-10-20T08:15:00Z\",\n \"price\": 0\n },\n {\n \"ticketId\": \"TCK-002\",\n \"title\": \"Quarterly budget report\",\n \"description\": \"Prepare and submit the Q4 budget report.\",\n \"status\": \"in_progress\",\n \"priority\": \"medium\",\n \"category\": \"finance\",\n \"assignee\": \"finance_team\",\n \"createdAt\": \"2025-09-15T11:30:00Z\",\n \"price\": 0\n },\n {\n \"ticketId\": \"TCK-003\",\n \"title\": \"User onboarding workflow\",\n \"description\": \"Design and implement a new onboarding workflow for new hires.\",\n \"status\": \"resolved\",\n \"priority\": \"low\",\n \"category\": \"hr\",\n \"assignee\": \"hr_manager\",\n \"createdAt\": \"2025-08-01T09:00:00Z\",\n \"price\": 0\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Show open tickets\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Here are the open tickets...\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"List high priority tickets\",\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": [\n {\n \"term\": {\n \"priority\": \"high\"\n }\n }\n ]\n }\n },\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n }\n]\n\nUser Query: Show open high priority network tickets assigned to tech support\n\nRephrased Query: List open tickets with high priority, category network, assigned to tech_support\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": [\n {\n \"term\": {\n \"status\": \"open\"\n }\n },\n {\n \"term\": {\n \"priority\": \"high\"\n }\n },\n {\n \"term\": {\n \"category\": \"network\"\n }\n },\n {\n \"term\": {\n \"assignee\": \"tech_support\"\n }\n }\n ]\n }\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n}" } ]
{ "domain": "Project Management Tasks", "data_type": "structured", "query_type": "listing_with_filters", "pattern": "initial", "pattern_type": "categorical_listing", "size": 10, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: Academic Articles - Policy Documents\n\nField Mappings:\n{\n \"properties\": {\n \"documentId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"author\": {\n \"type\": \"keyword\"\n },\n \"department\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"fileType\": {\n \"type\": \"keyword\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"tags\": {\n \"type\": \"keyword\"\n },\n \"confidentialityLevel\": {\n \"type\": \"keyword\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"documentId\": \"DOC-001\",\n \"title\": \"IT Security Policy Overview\",\n \"author\": \"alice.smith\",\n \"department\": \"IT Security\",\n \"createdAt\": \"2024-02-15\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"policy\",\n \"tags\": [\n \"security\",\n \"policy\",\n \"overview\"\n ],\n \"confidentialityLevel\": \"internal\"\n },\n {\n \"documentId\": \"DOC-002\",\n \"title\": \"Remote Work Guidelines\",\n \"author\": \"bob.johnson\",\n \"department\": \"Human Resources\",\n \"createdAt\": \"2023-11-01\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"guideline\",\n \"tags\": [\n \"remote\",\n \"work\",\n \"policy\"\n ],\n \"confidentialityLevel\": \"public\"\n },\n {\n \"documentId\": \"DOC-003\",\n \"title\": \"Finance Department Data Retention Policy\",\n \"author\": \"carla.lee\",\n \"department\": \"Finance\",\n \"createdAt\": \"2024-05-20\",\n \"fileType\": \"pdf\",\n \"status\": \"draft\",\n \"category\": \"policy\",\n \"tags\": [\n \"data\",\n \"retention\",\n \"finance\"\n ],\n \"confidentialityLevel\": \"confidential\"\n },\n {\n \"documentId\": \"DOC-004\",\n \"title\": \"IT Security Incident Response Procedure\",\n \"author\": \"david.khan\",\n \"department\": \"IT Security\",\n \"createdAt\": \"2024-01-10\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"procedure\",\n \"tags\": [\n \"incident\",\n \"response\",\n \"security\"\n ],\n \"confidentialityLevel\": \"internal\"\n },\n {\n \"documentId\": \"DOC-005\",\n \"title\": \"Annual Compliance Report 2023\",\n \"author\": \"emma.wong\",\n \"department\": \"Compliance\",\n \"createdAt\": \"2024-03-05\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"report\",\n \"tags\": [\n \"compliance\",\n \"annual\",\n \"2023\"\n ],\n \"confidentialityLevel\": \"public\"\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Can you list the latest security policies?\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, here are the most recent approved security policies...\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"Show me 10 recent documents\",\n \"dsl_type\": \"semantic_search\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"match\": {\n \"title\": \"policy\"\n }\n }\n }\n }\n]\n\nUser Query: Show me 39 approved policy documents from the IT Security department\n\nRephrased Query: Retrieve 39 documents where status is approved, department is IT Security, and fileType is pdf\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"hybrid_search_with_filters\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 39,\n \"from\": 0,\n \"query\": {\n \"hybrid\": {\n \"text\": \"approved policy\",\n \"embedding\": {\n \"vector\": [\n 0,\n 0,\n 0,\n \"...\"\n ],\n \"k\": 39\n },\n \"filter\": {\n \"bool\": {\n \"must\": [\n {\n \"term\": {\n \"status\": \"approved\"\n }\n },\n {\n \"term\": {\n \"department\": \"IT Security\"\n }\n },\n {\n \"term\": {\n \"fileType\": \"pdf\"\n }\n },\n {\n \"range\": {\n \"createdAt\": {\n \"gte\": \"2023-01-01\"\n }\n }\n }\n ]\n }\n }\n }\n }\n }\n}" } ]
{ "domain": "Academic Articles - Policy Documents", "data_type": "unstructured", "query_type": "hybrid_search_with_filters", "pattern": "refinement", "pattern_type": "add_filter", "size": 39, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: Sales Orders\n\nField Mappings:\n{\n \"properties\": {\n \"ticketId\": {\n \"type\": \"keyword\"\n },\n \"productId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"description\": {\n \"type\": \"text\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"priority\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"assignee\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"price\": {\n \"type\": \"float\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"ticketId\": \"TCKT-1001\",\n \"productId\": \"PRD-2001\",\n \"title\": \"Order #1001 for Widget A\",\n \"description\": \"Customer requested 50 units of Widget A, shipping to New York.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"hardware\",\n \"assignee\": \"alice.smith\",\n \"createdAt\": \"2025-10-20T08:15:30Z\",\n \"price\": 1250,\n \"documentContentWordsChunked\": [\n {\n \"passage\": \"Customer requested 50 units of Widget A.\",\n \"embedding\": [\n 0,\n 0,\n 0\n ]\n }\n ]\n },\n {\n \"ticketId\": \"TCKT-1002\",\n \"productId\": \"PRD-2002\",\n \"title\": \"Order #1002 for Service B\",\n \"description\": \"Annual maintenance contract for Service B, start date 2025-11-01.\",\n \"status\": \"closed\",\n \"priority\": \"medium\",\n \"category\": \"services\",\n \"assignee\": \"bob.jones\",\n \"createdAt\": \"2025-09-15T14:42:10Z\",\n \"price\": 3000,\n \"documentContentWordsChunked\": [\n {\n \"passage\": \"Annual maintenance contract for Service B.\",\n \"embedding\": [\n 0,\n 0,\n 0\n ]\n }\n ]\n },\n {\n \"ticketId\": \"TCKT-1003\",\n \"productId\": \"PRD-2003\",\n \"title\": \"Order #1003 for Software C\",\n \"description\": \"License renewal for Software C, 200 seats.\",\n \"status\": \"in_progress\",\n \"priority\": \"low\",\n \"category\": \"software\",\n \"assignee\": \"carol.lee\",\n \"createdAt\": \"2025-11-01T09:05:45Z\",\n \"price\": 7200,\n \"documentContentWordsChunked\": [\n {\n \"passage\": \"License renewal for Software C, 200 seats.\",\n \"embedding\": [\n 0,\n 0,\n 0\n ]\n }\n ]\n }\n]\n\nChat History:\n[]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"Show tickets\",\n \"dsl_type\": \"listing\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"match_all\": {}\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ],\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n }\n }\n }\n]\n\nUser Query: Show tickets\n\nRephrased Query: List all tickets\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"listing\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"match_all\": {}\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n}" } ]
{ "domain": "Sales Orders", "data_type": "structured", "query_type": "listing", "pattern": "initial", "pattern_type": "sorted_listing", "size": 10, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: Legal Policies Repository\n\nField Mappings:\n{\n \"properties\": {\n \"documentId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"author\": {\n \"type\": \"keyword\"\n },\n \"department\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"fileType\": {\n \"type\": \"keyword\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"tags\": {\n \"type\": \"keyword\"\n },\n \"confidentialityLevel\": {\n \"type\": \"keyword\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"documentId\": \"DOC-001\",\n \"title\": \"IT Security Approved Policy\",\n \"author\": \"Alice Johnson\",\n \"department\": \"IT Security\",\n \"createdAt\": \"2024-02-15\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"policy\",\n \"tags\": [\n \"security\",\n \"access\",\n \"encryption\"\n ],\n \"confidentialityLevel\": \"internal\"\n },\n {\n \"documentId\": \"DOC-002\",\n \"title\": \"Finance Quarterly Report 2024 Q1\",\n \"author\": \"Bob Martinez\",\n \"department\": \"Finance\",\n \"createdAt\": \"2024-04-10\",\n \"fileType\": \"pdf\",\n \"status\": \"draft\",\n \"category\": \"report\",\n \"tags\": [\n \"financial\",\n \"quarterly\",\n \"2024\"\n ],\n \"confidentialityLevel\": \"confidential\"\n },\n {\n \"documentId\": \"DOC-003\",\n \"title\": \"Remote Work Guidelines\",\n \"author\": \"Carol Lee\",\n \"department\": \"Human Resources\",\n \"createdAt\": \"2023-11-01\",\n \"fileType\": \"docx\",\n \"status\": \"approved\",\n \"category\": \"guideline\",\n \"tags\": [\n \"remote\",\n \"work\",\n \"policy\"\n ],\n \"confidentialityLevel\": \"public\"\n },\n {\n \"documentId\": \"DOC-004\",\n \"title\": \"Data Protection Act Summary\",\n \"author\": \"David Kim\",\n \"department\": \"Legal\",\n \"createdAt\": \"2024-01-20\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"policy\",\n \"tags\": [\n \"data\",\n \"privacy\",\n \"compliance\"\n ],\n \"confidentialityLevel\": \"internal\"\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"List PDFs from Finance department after 2024\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, retrieving PDF documents from Finance created after 2024...\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"List PDFs from Finance department after 2024\",\n \"dsl_type\": \"hybrid_search_with_filters\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"hybrid\": {\n \"vector\": {\n \"field\": \"documentContentWordsChunked.embedding\",\n \"query_vector\": [],\n \"k\": 10\n },\n \"filter\": {\n \"bool\": {\n \"must\": [\n {\n \"term\": {\n \"fileType\": \"pdf\"\n }\n },\n {\n \"term\": {\n \"department\": \"Finance\"\n }\n },\n {\n \"range\": {\n \"createdAt\": {\n \"gt\": \"2024-01-01\"\n }\n }\n }\n ]\n }\n }\n }\n },\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n }\n }\n }\n]\n\nUser Query: Show approved policies from IT Security\n\nRephrased Query: Retrieve approved policy documents belonging to the IT Security department\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"hybrid_search_with_filters\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"hybrid\": {\n \"vector\": {\n \"field\": \"documentContentWordsChunked.embedding\",\n \"query_vector\": [],\n \"k\": 10\n },\n \"filter\": {\n \"bool\": {\n \"must\": [\n {\n \"term\": {\n \"status\": \"approved\"\n }\n },\n {\n \"term\": {\n \"department\": \"IT Security\"\n }\n }\n ]\n }\n }\n }\n }\n }\n}" } ]
{ "domain": "Legal Policies Repository", "data_type": "unstructured", "query_type": "hybrid_search_with_filters", "pattern": "initial", "pattern_type": "complex_query", "size": 10, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: Sales Orders\n\nField Mappings:\n{\n \"properties\": {\n \"orderId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"description\": {\n \"type\": \"text\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"priority\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"assignee\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"price\": {\n \"type\": \"float\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"orderId\": \"SO-1001\",\n \"title\": \"Order for Laptop Model X\",\n \"description\": \"Customer purchased 5 units of Laptop Model X with extended warranty.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"Electronics\",\n \"assignee\": \"tech_support\",\n \"createdAt\": \"2025-10-20T09:15:00Z\",\n \"price\": 7500\n },\n {\n \"orderId\": \"SO-1002\",\n \"title\": \"Office Furniture Bulk Order\",\n \"description\": \"Order includes 20 ergonomic chairs and 10 standing desks.\",\n \"status\": \"closed\",\n \"priority\": \"medium\",\n \"category\": \"Furniture\",\n \"assignee\": \"sales_rep_jane\",\n \"createdAt\": \"2025-09-15T14:30:00Z\",\n \"price\": 12400.5\n },\n {\n \"orderId\": \"SO-1003\",\n \"title\": \"Network Equipment Upgrade\",\n \"description\": \"Purchase of routers, switches, and firewalls for data center upgrade.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"Electronics\",\n \"assignee\": \"tech_support\",\n \"createdAt\": \"2025-10-18T11:45:00Z\",\n \"price\": 18200.75\n },\n {\n \"orderId\": \"SO-1004\",\n \"title\": \"Software License Renewal\",\n \"description\": \"Annual renewal of enterprise software licenses for 150 users.\",\n \"status\": \"pending\",\n \"priority\": \"low\",\n \"category\": \"Software\",\n \"assignee\": \"account_manager\",\n \"createdAt\": \"2025-10-01T08:00:00Z\",\n \"price\": 3000\n },\n {\n \"orderId\": \"SO-1005\",\n \"title\": \"Custom Server Build\",\n \"description\": \"Build and delivery of a custom high‑performance server for AI workloads.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"Electronics\",\n \"assignee\": \"tech_support\",\n \"createdAt\": \"2025-10-22T16:20:00Z\",\n \"price\": 25000\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Show me 22 open sales orders with high priority in the Electronics category.\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, I will retrieve the 22 most recent open, high‑priority Electronics orders for you.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"List 10 recent sales orders\",\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": []\n }\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n }\n]\n\nUser Query: Show me 22 open sales orders with high priority in the Electronics category.\n\nRephrased Query: Retrieve 22 documents where status is open, priority is high, and category is Electronics.\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 22,\n \"from\": 0,\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": [\n {\n \"term\": {\n \"status\": \"open\"\n }\n },\n {\n \"term\": {\n \"priority\": \"high\"\n }\n },\n {\n \"term\": {\n \"category\": \"Electronics\"\n }\n }\n ]\n }\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n}" } ]
{ "domain": "Sales Orders", "data_type": "structured", "query_type": "listing_with_filters", "pattern": "initial", "pattern_type": "filtered_search", "size": 22, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: HR Employee Ticketing System\n\nField Mappings:\n{\n \"properties\": {\n \"ticketId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"description\": {\n \"type\": \"text\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"priority\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"assignee\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"price\": {\n \"type\": \"float\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"ticketId\": \"TCK-001\",\n \"title\": \"Network outage in building A\",\n \"description\": \"Employees cannot access the internet on the 3rd floor.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"network\",\n \"assignee\": \"tech_support\",\n \"createdAt\": \"2025-10-20T08:15:00Z\",\n \"price\": 0\n },\n {\n \"ticketId\": \"TCK-002\",\n \"title\": \"Payroll discrepancy for March\",\n \"description\": \"Incorrect salary amount credited to employee John Doe.\",\n \"status\": \"resolved\",\n \"priority\": \"medium\",\n \"category\": \"payroll\",\n \"assignee\": \"hr_specialist\",\n \"createdAt\": \"2025-03-15T14:30:00Z\",\n \"price\": 0\n },\n {\n \"ticketId\": \"TCK-003\",\n \"title\": \"Laptop battery replacement request\",\n \"description\": \"Battery health below 20% for employee Jane Smith's laptop.\",\n \"status\": \"in_progress\",\n \"priority\": \"low\",\n \"category\": \"hardware\",\n \"assignee\": \"it_support\",\n \"createdAt\": \"2025-11-01T09:45:00Z\",\n \"price\": 120.5\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Show open tickets\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Here are the currently open tickets.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"Show open tickets\",\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": [\n {\n \"term\": {\n \"status\": \"open\"\n }\n }\n ]\n }\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n }\n]\n\nUser Query: List high-priority network tickets assigned to tech support\n\nRephrased Query: Retrieve open tickets with priority high, category network, and assignee tech_support\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": [\n {\n \"term\": {\n \"status\": \"open\"\n }\n },\n {\n \"term\": {\n \"priority\": \"high\"\n }\n },\n {\n \"term\": {\n \"category\": \"network\"\n }\n },\n {\n \"term\": {\n \"assignee\": \"tech_support\"\n }\n }\n ]\n }\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n}" } ]
{ "domain": "HR Employee Ticketing System", "data_type": "structured", "query_type": "listing_with_filters", "pattern": "initial", "pattern_type": "keyword_search", "size": 10, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: Product Catalog\n\nField Mappings:\n{\n \"properties\": {\n \"productId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"description\": {\n \"type\": \"text\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"priority\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"assignee\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"price\": {\n \"type\": \"float\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"productId\": \"P1001\",\n \"title\": \"Wireless Noise‑Cancelling Headphones\",\n \"description\": \"Over‑ear headphones with active noise cancellation, 30‑hour battery life, and Bluetooth 5.2 connectivity.\",\n \"status\": \"available\",\n \"priority\": \"high\",\n \"category\": \"electronics\",\n \"assignee\": \"inventory_team\",\n \"createdAt\": \"2024-09-12T08:15:30Z\",\n \"price\": 199.99\n },\n {\n \"productId\": \"P1002\",\n \"title\": \"Ergonomic Office Chair\",\n \"description\": \"Adjustable lumbar support, breathable mesh back, and 360Β° swivel for maximum comfort during long work sessions.\",\n \"status\": \"available\",\n \"priority\": \"medium\",\n \"category\": \"furniture\",\n \"assignee\": \"sales_team\",\n \"createdAt\": \"2024-08-05T14:42:10Z\",\n \"price\": 349.5\n },\n {\n \"productId\": \"P1003\",\n \"title\": \"Smart Home Hub\",\n \"description\": \"Control lights, thermostats, and security cameras from a single app. Supports Alexa, Google Assistant, and Apple HomeKit.\",\n \"status\": \"out_of_stock\",\n \"priority\": \"high\",\n \"category\": \"smart_home\",\n \"assignee\": \"logistics_team\",\n \"createdAt\": \"2024-07-20T11:07:45Z\",\n \"price\": 129\n },\n {\n \"productId\": \"P1004\",\n \"title\": \"4K Ultra‑HD Monitor 27\\\"\",\n \"description\": \"IPS panel with 3840Γ—2160 resolution, 144β€―Hz refresh rate, and HDR support for stunning visual clarity.\",\n \"status\": \"available\",\n \"priority\": \"low\",\n \"category\": \"electronics\",\n \"assignee\": \"inventory_team\",\n \"createdAt\": \"2024-09-01T09:30:00Z\",\n \"price\": 449.99\n },\n {\n \"productId\": \"P1005\",\n \"title\": \"Stainless Steel Water Bottle 750β€―ml\",\n \"description\": \"Double‑wall insulated bottle keeps drinks cold for 24β€―hours or hot for 12β€―hours. BPA‑free and leak‑proof.\",\n \"status\": \"available\",\n \"priority\": \"medium\",\n \"category\": \"accessories\",\n \"assignee\": \"sales_team\",\n \"createdAt\": \"2024-08-22T16:20:55Z\",\n \"price\": 24.99\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Can you show me the latest products in the catalog?\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, here are the most recent items added to the catalog.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"list 10 recent items\",\n \"dsl_type\": \"listing\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"match_all\": {}\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n }\n]\n\nUser Query: Show me 48 products from the catalog\n\nRephrased Query: list 48 items without any filters\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"listing\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 48,\n \"from\": 0,\n \"query\": {\n \"match_all\": {}\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n}" } ]
{ "domain": "Product Catalog", "data_type": "structured", "query_type": "listing", "pattern": "initial", "pattern_type": "semantic_question", "size": 48, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: News Articles\n\nField Mappings:\n{\n \"properties\": {\n \"documentId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"author\": {\n \"type\": \"keyword\"\n },\n \"department\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"fileType\": {\n \"type\": \"keyword\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"tags\": {\n \"type\": \"keyword\"\n },\n \"confidentialityLevel\": {\n \"type\": \"keyword\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"documentId\": \"doc-001\",\n \"title\": \"IT Security Policy Overview\",\n \"author\": \"Alice Johnson\",\n \"department\": \"IT Security\",\n \"createdAt\": \"2024-03-15T09:30:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"policy\",\n \"tags\": [\n \"security\",\n \"policy\",\n \"overview\"\n ],\n \"confidentialityLevel\": \"internal\"\n },\n {\n \"documentId\": \"doc-002\",\n \"title\": \"Finance Quarterly Report Q1 2024\",\n \"author\": \"Bob Martinez\",\n \"department\": \"Finance\",\n \"createdAt\": \"2024-04-20T14:00:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"draft\",\n \"category\": \"report\",\n \"tags\": [\n \"finance\",\n \"quarterly\",\n \"Q1\"\n ],\n \"confidentialityLevel\": \"confidential\"\n },\n {\n \"documentId\": \"doc-003\",\n \"title\": \"Remote Work Guidelines\",\n \"author\": \"Carol Lee\",\n \"department\": \"Human Resources\",\n \"createdAt\": \"2023-11-05T08:15:00Z\",\n \"fileType\": \"docx\",\n \"status\": \"approved\",\n \"category\": \"guideline\",\n \"tags\": [\n \"remote\",\n \"work\",\n \"policy\"\n ],\n \"confidentialityLevel\": \"public\"\n },\n {\n \"documentId\": \"doc-004\",\n \"title\": \"Marketing Campaign Strategy 2024\",\n \"author\": \"David Kim\",\n \"department\": \"Marketing\",\n \"createdAt\": \"2024-01-10T11:45:00Z\",\n \"fileType\": \"pptx\",\n \"status\": \"approved\",\n \"category\": \"strategy\",\n \"tags\": [\n \"marketing\",\n \"campaign\",\n \"2024\"\n ],\n \"confidentialityLevel\": \"internal\"\n },\n {\n \"documentId\": \"doc-005\",\n \"title\": \"IT Security Incident Response Plan\",\n \"author\": \"Evelyn Smith\",\n \"department\": \"IT Security\",\n \"createdAt\": \"2024-02-28T16:20:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"plan\",\n \"tags\": [\n \"incident\",\n \"response\",\n \"security\"\n ],\n \"confidentialityLevel\": \"restricted\"\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"List PDFs from Finance department after 2024\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, retrieving PDF documents from Finance created after 2024...\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"List PDFs from Finance department after 2024\",\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": [\n {\n \"term\": {\n \"fileType\": \"pdf\"\n }\n },\n {\n \"term\": {\n \"department\": \"Finance\"\n }\n },\n {\n \"range\": {\n \"createdAt\": {\n \"gte\": \"2024-01-01T00:00:00Z\"\n }\n }\n }\n ]\n }\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n }\n]\n\nUser Query: Show approved policies from IT Security\n\nRephrased Query: List approved policy documents in the IT Security department\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": [\n {\n \"term\": {\n \"status\": \"approved\"\n }\n },\n {\n \"term\": {\n \"department\": \"IT Security\"\n }\n },\n {\n \"term\": {\n \"category\": \"policy\"\n }\n }\n ]\n }\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n}" } ]
{ "domain": "News Articles", "data_type": "unstructured", "query_type": "listing_with_filters", "pattern": "initial", "pattern_type": "categorical_listing", "size": 10, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: Social Media Posts\n\nField Mappings:\n{\n \"properties\": {\n \"documentId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"author\": {\n \"type\": \"keyword\"\n },\n \"department\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"fileType\": {\n \"type\": \"keyword\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"tags\": {\n \"type\": \"keyword\"\n },\n \"confidentialityLevel\": {\n \"type\": \"keyword\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"documentId\": \"post-001\",\n \"title\": \"Remote Work Tips\",\n \"author\": \"alice.smith\",\n \"department\": \"IT\",\n \"createdAt\": \"2024-03-12T09:15:00Z\",\n \"fileType\": \"text\",\n \"status\": \"published\",\n \"category\": \"productivity\",\n \"tags\": [\n \"remote\",\n \"work\",\n \"tips\"\n ],\n \"confidentialityLevel\": \"public\"\n },\n {\n \"documentId\": \"post-002\",\n \"title\": \"Company Security Policy Update\",\n \"author\": \"bob.johnson\",\n \"department\": \"Security\",\n \"createdAt\": \"2024-06-01T14:30:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"policy\",\n \"tags\": [\n \"security\",\n \"policy\",\n \"update\"\n ],\n \"confidentialityLevel\": \"internal\"\n },\n {\n \"documentId\": \"post-003\",\n \"title\": \"Celebrating 10 Years of Innovation\",\n \"author\": \"carol.lee\",\n \"department\": \"Marketing\",\n \"createdAt\": \"2024-01-20T11:00:00Z\",\n \"fileType\": \"image\",\n \"status\": \"published\",\n \"category\": \"announcement\",\n \"tags\": [\n \"anniversary\",\n \"innovation\"\n ],\n \"confidentialityLevel\": \"public\"\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Can you list the latest security policies?\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, here are the most recent security policies...\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"Show 10 recent posts\",\n \"dsl_type\": \"simple_search\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"match_all\": {}\n },\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n }\n }\n }\n]\n\nUser Query: Show $73 approved policies from IT Security\n\nRephrased Query: Retrieve 73 approved policy documents without any additional filters\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"hybrid_search\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 73,\n \"from\": 0,\n \"query\": {\n \"bool\": {\n \"should\": [\n {\n \"match_all\": {}\n },\n {\n \"knn\": {\n \"documentContentWordsChunked.embedding\": {\n \"vector\": [\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0.1\n ]\n }\n }\n }\n ]\n }\n }\n }\n}" } ]
{ "domain": "Social Media Posts", "data_type": "unstructured", "query_type": "hybrid_search", "pattern": "initial", "pattern_type": "sorted_listing", "size": 73, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: Supplier Contracts\n\nField Mappings:\n{\n \"properties\": {\n \"ticketId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"description\": {\n \"type\": \"text\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"priority\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"assignee\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"price\": {\n \"type\": \"float\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"ticketId\": \"SC-1001\",\n \"title\": \"Annual Supply Agreement for Office Supplies\",\n \"description\": \"Contract with Alpha Supplies for yearly delivery of office stationery.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"procurement\",\n \"assignee\": \"jane.doe\",\n \"createdAt\": \"2024-09-15T08:30:00Z\",\n \"price\": 12500,\n \"documentContentWordsChunked\": [\n {\n \"passage\": \"This agreement outlines the terms for the supply of office stationery...\",\n \"embedding\": [\n 0,\n 0,\n 0\n ]\n }\n ]\n },\n {\n \"ticketId\": \"SC-1002\",\n \"title\": \"Quarterly Maintenance Contract for HVAC Systems\",\n \"description\": \"Service contract with CoolAir Ltd. covering quarterly maintenance of HVAC units.\",\n \"status\": \"resolved\",\n \"priority\": \"medium\",\n \"category\": \"maintenance\",\n \"assignee\": \"john.smith\",\n \"createdAt\": \"2024-06-01T14:12:00Z\",\n \"price\": 8200.5,\n \"documentContentWordsChunked\": [\n {\n \"passage\": \"The maintenance schedule includes filter replacement and system diagnostics...\",\n \"embedding\": [\n 0,\n 0,\n 0\n ]\n }\n ]\n },\n {\n \"ticketId\": \"SC-1003\",\n \"title\": \"One‑Time Purchase of Raw Materials\",\n \"description\": \"One‑off purchase order for steel rods from MetalWorks Inc.\",\n \"status\": \"closed\",\n \"priority\": \"low\",\n \"category\": \"procurement\",\n \"assignee\": \"alice.wang\",\n \"createdAt\": \"2024-03-20T10:45:00Z\",\n \"price\": 45000.75,\n \"documentContentWordsChunked\": [\n {\n \"passage\": \"The order includes 5000 kg of high‑grade steel rods...\",\n \"embedding\": [\n 0,\n 0,\n 0\n ]\n }\n ]\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Show open tickets\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, retrieving all open tickets for you.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"List all tickets\",\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": []\n }\n },\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n }\n]\n\nUser Query: Show open tickets\n\nRephrased Query: List all tickets where status is open\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": [\n {\n \"term\": {\n \"status\": \"open\"\n }\n }\n ]\n }\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n}" } ]
{ "domain": "Supplier Contracts", "data_type": "structured", "query_type": "listing_with_filters", "pattern": "initial", "pattern_type": "semantic_question", "size": 10, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: Technical Manuals\n\nField Mappings:\n{\n \"properties\": {\n \"documentId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"author\": {\n \"type\": \"keyword\"\n },\n \"department\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"fileType\": {\n \"type\": \"keyword\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"tags\": {\n \"type\": \"keyword\"\n },\n \"confidentialityLevel\": {\n \"type\": \"keyword\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"documentId\": \"TM-001\",\n \"title\": \"IT Security Policy Overview\",\n \"author\": \"Alice Johnson\",\n \"department\": \"IT Security\",\n \"createdAt\": \"2023-11-15T09:30:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"policy\",\n \"tags\": [\n \"security\",\n \"policy\",\n \"overview\"\n ],\n \"confidentialityLevel\": \"internal\"\n },\n {\n \"documentId\": \"TM-002\",\n \"title\": \"Finance Department Expense Guidelines\",\n \"author\": \"Bob Martinez\",\n \"department\": \"Finance\",\n \"createdAt\": \"2024-02-10T14:45:00Z\",\n \"fileType\": \"docx\",\n \"status\": \"draft\",\n \"category\": \"guideline\",\n \"tags\": [\n \"expense\",\n \"finance\",\n \"guidelines\"\n ],\n \"confidentialityLevel\": \"confidential\"\n },\n {\n \"documentId\": \"TM-003\",\n \"title\": \"Remote Work Security Checklist\",\n \"author\": \"Carol Lee\",\n \"department\": \"IT Security\",\n \"createdAt\": \"2024-07-01T08:00:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"checklist\",\n \"tags\": [\n \"remote\",\n \"security\",\n \"checklist\"\n ],\n \"confidentialityLevel\": \"public\"\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Can you list the approved policies for IT Security?\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, I will retrieve the approved policies from the IT Security department.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"List PDFs from Finance department after 2024\",\n \"dsl_type\": \"hybrid_search_with_filters\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"query\": {\n \"hybrid\": {\n \"text\": \"\",\n \"filter\": {\n \"bool\": {\n \"must\": [\n {\n \"term\": {\n \"department\": \"Finance\"\n }\n },\n {\n \"term\": {\n \"fileType\": \"pdf\"\n }\n },\n {\n \"range\": {\n \"createdAt\": {\n \"gt\": \"2024-01-01T00:00:00Z\"\n }\n }\n }\n ]\n }\n }\n }\n }\n }\n }\n]\n\nUser Query: Show approved policies from IT Security\n\nRephrased Query: List approved policies in the IT Security department\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"hybrid_search_with_filters\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"hybrid\": {\n \"text\": \"\",\n \"filter\": {\n \"bool\": {\n \"must\": [\n {\n \"term\": {\n \"status\": \"approved\"\n }\n },\n {\n \"term\": {\n \"department\": \"IT Security\"\n }\n }\n ]\n }\n }\n }\n }\n }\n}" } ]
{ "domain": "Technical Manuals", "data_type": "unstructured", "query_type": "hybrid_search_with_filters", "pattern": "initial", "pattern_type": "sorted_listing", "size": 10, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: Supplier Contracts\n\nField Mappings:\n{\n \"properties\": {\n \"ticketId\": {\n \"type\": \"keyword\"\n },\n \"productId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"description\": {\n \"type\": \"text\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"priority\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"assignee\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"price\": {\n \"type\": \"float\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"ticketId\": \"TCK-1001\",\n \"productId\": \"PRD-2001\",\n \"title\": \"Annual Supplier Contract Renewal\",\n \"description\": \"Renewal of the annual contract with Supplier A for raw material supply.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"contract\",\n \"assignee\": \"jane.doe\",\n \"createdAt\": \"2024-10-05T09:15:00Z\",\n \"price\": 125000\n },\n {\n \"ticketId\": \"TCK-1002\",\n \"productId\": \"PRD-2002\",\n \"title\": \"Contract Amendment Request\",\n \"description\": \"Request to amend delivery terms for Supplier B due to new logistics constraints.\",\n \"status\": \"in_progress\",\n \"priority\": \"medium\",\n \"category\": \"amendment\",\n \"assignee\": \"john.smith\",\n \"createdAt\": \"2024-09-28T14:42:00Z\",\n \"price\": 0\n },\n {\n \"ticketId\": \"TCK-1003\",\n \"productId\": \"PRD-2003\",\n \"title\": \"Closed Contract Archive\",\n \"description\": \"Archive of the closed contract with Supplier C for the fiscal year 2022.\",\n \"status\": \"closed\",\n \"priority\": \"low\",\n \"category\": \"archive\",\n \"assignee\": \"alice.wang\",\n \"createdAt\": \"2023-12-15T11:00:00Z\",\n \"price\": 98000\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Can you list all open tickets for supplier contracts?\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, here are the open tickets...\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"Show tickets\",\n \"dsl_type\": \"listing\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"match_all\": {}\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ],\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n }\n }\n }\n]\n\nUser Query: Show tickets\n\nRephrased Query: List all tickets without any filters\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"listing\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"match_all\": {}\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n}" } ]
{ "domain": "Supplier Contracts", "data_type": "structured", "query_type": "listing", "pattern": "initial", "pattern_type": "keyword_search", "size": 10, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: Customer Support Tickets\n\nField Mappings:\n{\n \"properties\": {\n \"documentId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"author\": {\n \"type\": \"keyword\"\n },\n \"department\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"fileType\": {\n \"type\": \"keyword\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"tags\": {\n \"type\": \"keyword\"\n },\n \"confidentialityLevel\": {\n \"type\": \"keyword\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"documentId\": \"TCKT-001\",\n \"title\": \"Quarterly Financial Report Q1\",\n \"author\": \"alice.smith\",\n \"department\": \"Finance\",\n \"createdAt\": \"2024-02-15T09:30:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"open\",\n \"category\": \"report\",\n \"tags\": [\n \"finance\",\n \"quarterly\",\n \"Q1\"\n ],\n \"confidentialityLevel\": \"high\"\n },\n {\n \"documentId\": \"TCKT-002\",\n \"title\": \"IT Security Policy Update\",\n \"author\": \"bob.johnson\",\n \"department\": \"IT Security\",\n \"createdAt\": \"2024-03-10T14:12:00Z\",\n \"fileType\": \"docx\",\n \"status\": \"approved\",\n \"category\": \"policy\",\n \"tags\": [\n \"security\",\n \"policy\",\n \"update\"\n ],\n \"confidentialityLevel\": \"medium\"\n },\n {\n \"documentId\": \"TCKT-003\",\n \"title\": \"Employee Remote Work Guidelines\",\n \"author\": \"carol.lee\",\n \"department\": \"HR\",\n \"createdAt\": \"2023-12-01T08:00:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"closed\",\n \"category\": \"guideline\",\n \"tags\": [\n \"remote\",\n \"work\",\n \"guideline\"\n ],\n \"confidentialityLevel\": \"low\"\n },\n {\n \"documentId\": \"TCKT-004\",\n \"title\": \"Vendor Contract Review\",\n \"author\": \"dave.kim\",\n \"department\": \"Legal\",\n \"createdAt\": \"2024-01-20T11:45:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"open\",\n \"category\": \"contract\",\n \"tags\": [\n \"vendor\",\n \"contract\",\n \"review\"\n ],\n \"confidentialityLevel\": \"high\"\n },\n {\n \"documentId\": \"TCKT-005\",\n \"title\": \"Marketing Campaign Performance\",\n \"author\": \"eve.martinez\",\n \"department\": \"Marketing\",\n \"createdAt\": \"2024-04-05T10:20:00Z\",\n \"fileType\": \"xlsx\",\n \"status\": \"approved\",\n \"category\": \"report\",\n \"tags\": [\n \"marketing\",\n \"campaign\",\n \"performance\"\n ],\n \"confidentialityLevel\": \"medium\"\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Can you list the open tickets from Finance after January 2024?\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, I will retrieve open Finance tickets created on or after 2024-01-01.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"Show open tickets from Finance after 2024-01-01\",\n \"dsl_type\": \"hybrid_search_with_filters\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"query\": {\n \"hybrid\": {\n \"vector\": {\n \"field\": \"documentContentWordsChunked.embedding\",\n \"query_vector\": []\n },\n \"text\": {\n \"field\": \"documentContentWordsChunked.passage\",\n \"query\": \"open tickets\"\n },\n \"filter\": {\n \"bool\": {\n \"must\": [\n {\n \"term\": {\n \"department\": \"Finance\"\n }\n },\n {\n \"term\": {\n \"status\": \"open\"\n }\n },\n {\n \"range\": {\n \"createdAt\": {\n \"gte\": \"2024-01-01\"\n }\n }\n }\n ]\n }\n }\n }\n }\n }\n }\n]\n\nUser Query: List approved policies from IT Security\n\nRephrased Query: Retrieve documents with status approved, category policy, from the IT Security department\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"hybrid_search_with_filters\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"hybrid\": {\n \"vector\": {\n \"field\": \"documentContentWordsChunked.embedding\",\n \"query_vector\": []\n },\n \"text\": {\n \"field\": \"documentContentWordsChunked.passage\",\n \"query\": \"approved policies\"\n },\n \"filter\": {\n \"bool\": {\n \"must\": [\n {\n \"term\": {\n \"department\": \"IT Security\"\n }\n },\n {\n \"term\": {\n \"status\": \"approved\"\n }\n },\n {\n \"term\": {\n \"category\": \"policy\"\n }\n }\n ]\n }\n }\n }\n }\n }\n}" } ]
{ "domain": "Customer Support Tickets", "data_type": "unstructured", "query_type": "hybrid_search_with_filters", "pattern": "initial", "pattern_type": "filtered_search", "size": 10, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: Marketing Campaigns\n\nField Mappings:\n{\n \"properties\": {\n \"documentId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"description\": {\n \"type\": \"text\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"priority\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"assignee\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"price\": {\n \"type\": \"float\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"documentId\": \"MC-001\",\n \"title\": \"Spring Launch Email Blast\",\n \"description\": \"Email campaign for the spring product line targeting existing customers.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"email\",\n \"assignee\": \"john.doe\",\n \"createdAt\": \"2024-03-05T09:12:00Z\",\n \"price\": 1250\n },\n {\n \"documentId\": \"MC-002\",\n \"title\": \"Social Media Influencer Partnership\",\n \"description\": \"Collaboration with micro‑influencers for the summer collection.\",\n \"status\": \"in_progress\",\n \"priority\": \"medium\",\n \"category\": \"social\",\n \"assignee\": \"jane.smith\",\n \"createdAt\": \"2024-04-12T14:45:00Z\",\n \"price\": 3000\n },\n {\n \"documentId\": \"MC-003\",\n \"title\": \"Quarterly SEO Audit\",\n \"description\": \"Comprehensive SEO performance review and recommendations.\",\n \"status\": \"closed\",\n \"priority\": \"low\",\n \"category\": \"seo\",\n \"assignee\": \"alex.lee\",\n \"createdAt\": \"2024-01-20T08:30:00Z\",\n \"price\": 800\n },\n {\n \"documentId\": \"MC-004\",\n \"title\": \"Holiday Promo Video Production\",\n \"description\": \"Production of a 30‑second video for holiday promotions across TV and digital.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"video\",\n \"assignee\": \"john.doe\",\n \"createdAt\": \"2024-05-02T11:00:00Z\",\n \"price\": 4500\n },\n {\n \"documentId\": \"MC-005\",\n \"title\": \"Landing Page A/B Test\",\n \"description\": \"Testing two variants of the landing page for the new product launch.\",\n \"status\": \"in_progress\",\n \"priority\": \"high\",\n \"category\": \"web\",\n \"assignee\": \"sara.kim\",\n \"createdAt\": \"2024-04-28T16:20:00Z\",\n \"price\": 1500\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Show me 10 recent marketing tickets.\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Here are the latest 10 tickets from the Marketing Campaigns index.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"list 10 tickets\",\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": []\n }\n }\n }\n }\n]\n\nUser Query: Show me 19 high‑priority open tickets assigned to John\n\nRephrased Query: Retrieve 19 open marketing tickets with high priority that are assigned to john.doe\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 19,\n \"from\": 0,\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": [\n {\n \"term\": {\n \"status\": \"open\"\n }\n },\n {\n \"term\": {\n \"priority\": \"high\"\n }\n },\n {\n \"term\": {\n \"assignee\": \"john.doe\"\n }\n }\n ]\n }\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n}" } ]
{ "domain": "Marketing Campaigns", "data_type": "structured", "query_type": "listing_with_filters", "pattern": "initial", "pattern_type": "categorical_listing", "size": 19, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: Social Media Posts\n\nField Mappings:\n{\n \"properties\": {\n \"documentId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"author\": {\n \"type\": \"keyword\"\n },\n \"department\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"fileType\": {\n \"type\": \"keyword\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"tags\": {\n \"type\": \"keyword\"\n },\n \"confidentialityLevel\": {\n \"type\": \"keyword\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"documentId\": \"post-001\",\n \"title\": \"Quarterly Security Update\",\n \"author\": \"alice.smith\",\n \"department\": \"IT Security\",\n \"createdAt\": \"2024-07-15T09:30:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"policy\",\n \"tags\": [\n \"security\",\n \"update\",\n \"quarterly\"\n ],\n \"confidentialityLevel\": \"internal\"\n },\n {\n \"documentId\": \"post-002\",\n \"title\": \"Remote Work Guidelines\",\n \"author\": \"bob.jones\",\n \"department\": \"HR\",\n \"createdAt\": \"2024-03-01T14:12:00Z\",\n \"fileType\": \"docx\",\n \"status\": \"draft\",\n \"category\": \"guideline\",\n \"tags\": [\n \"remote\",\n \"work\",\n \"policy\"\n ],\n \"confidentialityLevel\": \"public\"\n },\n {\n \"documentId\": \"post-003\",\n \"title\": \"Annual Financial Report\",\n \"author\": \"carla.lee\",\n \"department\": \"Finance\",\n \"createdAt\": \"2024-01-20T11:45:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"report\",\n \"tags\": [\n \"finance\",\n \"annual\",\n \"report\"\n ],\n \"confidentialityLevel\": \"confidential\"\n },\n {\n \"documentId\": \"post-004\",\n \"title\": \"Team Building Event Recap\",\n \"author\": \"david.kim\",\n \"department\": \"Marketing\",\n \"createdAt\": \"2024-06-05T16:00:00Z\",\n \"fileType\": \"jpg\",\n \"status\": \"published\",\n \"category\": \"event\",\n \"tags\": [\n \"team\",\n \"building\",\n \"recap\"\n ],\n \"confidentialityLevel\": \"public\"\n },\n {\n \"documentId\": \"post-005\",\n \"title\": \"Cybersecurity Awareness Training\",\n \"author\": \"eve.martinez\",\n \"department\": \"IT Security\",\n \"createdAt\": \"2024-08-10T08:20:00Z\",\n \"fileType\": \"mp4\",\n \"status\": \"approved\",\n \"category\": \"training\",\n \"tags\": [\n \"cybersecurity\",\n \"awareness\",\n \"training\"\n ],\n \"confidentialityLevel\": \"internal\"\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Show tickets\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, retrieving the latest tickets for you.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"Show tickets\",\n \"dsl_type\": \"hybrid_search\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"match_all\": {}\n }\n }\n }\n]\n\nUser Query: Show tickets\n\nRephrased Query: List recent tickets without any filters\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"hybrid_search\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"match_all\": {}\n }\n }\n}" } ]
{ "domain": "Social Media Posts", "data_type": "unstructured", "query_type": "hybrid_search", "pattern": "initial", "pattern_type": "categorical_listing", "size": 10, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: Medical Records\n\nField Mappings:\n{\n \"properties\": {\n \"documentId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"author\": {\n \"type\": \"keyword\"\n },\n \"department\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"fileType\": {\n \"type\": \"keyword\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"tags\": {\n \"type\": \"keyword\"\n },\n \"confidentialityLevel\": {\n \"type\": \"keyword\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"documentId\": \"MR-001\",\n \"title\": \"Annual Cardiology Report 2023\",\n \"author\": \"dr.smith\",\n \"department\": \"Cardiology\",\n \"createdAt\": \"2023-12-15\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"report\",\n \"tags\": [\n \"cardiology\",\n \"annual\",\n \"2023\"\n ],\n \"confidentialityLevel\": \"high\"\n },\n {\n \"documentId\": \"MR-002\",\n \"title\": \"Radiology Imaging Guidelines\",\n \"author\": \"dr.jones\",\n \"department\": \"Radiology\",\n \"createdAt\": \"2024-02-10\",\n \"fileType\": \"pdf\",\n \"status\": \"draft\",\n \"category\": \"guideline\",\n \"tags\": [\n \"imaging\",\n \"guidelines\"\n ],\n \"confidentialityLevel\": \"medium\"\n },\n {\n \"documentId\": \"MR-003\",\n \"title\": \"Finance Department Budget 2025\",\n \"author\": \"finance.team\",\n \"department\": \"Finance\",\n \"createdAt\": \"2025-01-05\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"budget\",\n \"tags\": [\n \"budget\",\n \"2025\"\n ],\n \"confidentialityLevel\": \"high\"\n },\n {\n \"documentId\": \"MR-004\",\n \"title\": \"Patient Privacy Policy\",\n \"author\": \"legal.dept\",\n \"department\": \"Legal\",\n \"createdAt\": \"2024-06-20\",\n \"fileType\": \"docx\",\n \"status\": \"approved\",\n \"category\": \"policy\",\n \"tags\": [\n \"privacy\",\n \"policy\"\n ],\n \"confidentialityLevel\": \"high\"\n },\n {\n \"documentId\": \"MR-005\",\n \"title\": \"IT Security Incident Report Q3 2024\",\n \"author\": \"it.security\",\n \"department\": \"IT Security\",\n \"createdAt\": \"2024-09-30\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"incident\",\n \"tags\": [\n \"security\",\n \"incident\",\n \"2024\"\n ],\n \"confidentialityLevel\": \"high\"\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Can you show me the latest approved policies from IT Security?\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, I will retrieve the approved policy documents from the IT Security department.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"List PDFs from Finance department after 2024\",\n \"dsl_type\": \"hybrid_search_with_filters\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"text_expansion\": {\n \"model_id\": \"text-embedding-768\",\n \"fields\": [\n \"title\",\n \"tags\"\n ]\n }\n }\n ],\n \"filter\": {\n \"bool\": {\n \"must\": [\n {\n \"term\": {\n \"fileType\": \"pdf\"\n }\n },\n {\n \"term\": {\n \"department\": \"Finance\"\n }\n },\n {\n \"range\": {\n \"createdAt\": {\n \"gt\": \"2024-01-01\"\n }\n }\n }\n ]\n }\n }\n }\n }\n }\n }\n]\n\nUser Query: List PDFs from Finance department after 2024\n\nRephrased Query: Retrieve PDF documents in the Finance department with a creation date later than 2024-01-01\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"hybrid_search_with_filters\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"text_expansion\": {\n \"model_id\": \"text-embedding-768\",\n \"fields\": [\n \"title\",\n \"tags\"\n ]\n }\n }\n ],\n \"filter\": {\n \"bool\": {\n \"must\": [\n {\n \"term\": {\n \"fileType\": \"pdf\"\n }\n },\n {\n \"term\": {\n \"department\": \"Finance\"\n }\n },\n {\n \"range\": {\n \"createdAt\": {\n \"gt\": \"2024-01-01\"\n }\n }\n }\n ]\n }\n }\n }\n }\n }\n}" } ]
{ "domain": "Medical Records", "data_type": "unstructured", "query_type": "hybrid_search_with_filters", "pattern": "initial", "pattern_type": "keyword_search", "size": 10, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: Social Media Posts\n\nField Mappings:\n{\n \"properties\": {\n \"documentId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"author\": {\n \"type\": \"keyword\"\n },\n \"department\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"fileType\": {\n \"type\": \"keyword\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"tags\": {\n \"type\": \"keyword\"\n },\n \"confidentialityLevel\": {\n \"type\": \"keyword\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"documentId\": \"doc-001\",\n \"title\": \"IT Security Policy Overview\",\n \"author\": \"alice.smith\",\n \"department\": \"IT Security\",\n \"createdAt\": \"2024-03-15T09:30:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"policy\",\n \"tags\": [\n \"security\",\n \"policy\",\n \"overview\"\n ],\n \"confidentialityLevel\": \"internal\"\n },\n {\n \"documentId\": \"doc-002\",\n \"title\": \"Finance Quarterly Report Q1 2024\",\n \"author\": \"bob.jones\",\n \"department\": \"Finance\",\n \"createdAt\": \"2024-04-20T14:10:00Z\",\n \"fileType\": \"xlsx\",\n \"status\": \"draft\",\n \"category\": \"report\",\n \"tags\": [\n \"finance\",\n \"quarterly\",\n \"2024\"\n ],\n \"confidentialityLevel\": \"confidential\"\n },\n {\n \"documentId\": \"doc-003\",\n \"title\": \"Remote Work Guidelines\",\n \"author\": \"carol.lee\",\n \"department\": \"Human Resources\",\n \"createdAt\": \"2023-12-01T08:00:00Z\",\n \"fileType\": \"docx\",\n \"status\": \"approved\",\n \"category\": \"guideline\",\n \"tags\": [\n \"remote\",\n \"work\",\n \"policy\"\n ],\n \"confidentialityLevel\": \"public\"\n },\n {\n \"documentId\": \"doc-004\",\n \"title\": \"Marketing Campaign Plan 2024\",\n \"author\": \"dave.kumar\",\n \"department\": \"Marketing\",\n \"createdAt\": \"2024-01-10T11:45:00Z\",\n \"fileType\": \"pptx\",\n \"status\": \"approved\",\n \"category\": \"plan\",\n \"tags\": [\n \"marketing\",\n \"campaign\",\n \"2024\"\n ],\n \"confidentialityLevel\": \"internal\"\n },\n {\n \"documentId\": \"doc-005\",\n \"title\": \"Security Incident Response Procedure\",\n \"author\": \"eve.wang\",\n \"department\": \"IT Security\",\n \"createdAt\": \"2024-02-28T16:20:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"procedure\",\n \"tags\": [\n \"incident\",\n \"response\",\n \"security\"\n ],\n \"confidentialityLevel\": \"confidential\"\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"List PDFs from Finance department after 2024\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, retrieving PDF documents from Finance created after Jan 1, 2024.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"List PDFs from Finance department after 2024\",\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": [\n {\n \"term\": {\n \"fileType\": \"pdf\"\n }\n },\n {\n \"term\": {\n \"department\": \"Finance\"\n }\n },\n {\n \"range\": {\n \"createdAt\": {\n \"gte\": \"2024-01-01T00:00:00Z\"\n }\n }\n }\n ]\n }\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n }\n]\n\nUser Query: Show approved policies from IT Security\n\nRephrased Query: List approved policy documents where status is approved and department is IT Security\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": [\n {\n \"term\": {\n \"status\": \"approved\"\n }\n },\n {\n \"term\": {\n \"department\": \"IT Security\"\n }\n },\n {\n \"term\": {\n \"category\": \"policy\"\n }\n }\n ]\n }\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n}" } ]
{ "domain": "Social Media Posts", "data_type": "unstructured", "query_type": "listing_with_filters", "pattern": "initial", "pattern_type": "filtered_search", "size": 10, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: Blog Posts\n\nField Mappings:\n{\n \"properties\": {\n \"documentId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"author\": {\n \"type\": \"keyword\"\n },\n \"department\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"fileType\": {\n \"type\": \"keyword\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"tags\": {\n \"type\": \"keyword\"\n },\n \"confidentialityLevel\": {\n \"type\": \"keyword\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"documentId\": \"doc-001\",\n \"title\": \"Quarterly Financial Report Q1 2024\",\n \"author\": \"alice.smith\",\n \"department\": \"Finance\",\n \"createdAt\": \"2024-04-15T09:30:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"report\",\n \"tags\": [\n \"finance\",\n \"quarterly\",\n \"2024\"\n ],\n \"confidentialityLevel\": \"internal\"\n },\n {\n \"documentId\": \"doc-002\",\n \"title\": \"IT Security Policy Update\",\n \"author\": \"bob.johnson\",\n \"department\": \"IT Security\",\n \"createdAt\": \"2024-02-20T14:00:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"policy\",\n \"tags\": [\n \"security\",\n \"policy\",\n \"update\"\n ],\n \"confidentialityLevel\": \"confidential\"\n },\n {\n \"documentId\": \"doc-003\",\n \"title\": \"Remote Work Guidelines\",\n \"author\": \"carol.lee\",\n \"department\": \"Human Resources\",\n \"createdAt\": \"2023-12-05T11:15:00Z\",\n \"fileType\": \"docx\",\n \"status\": \"draft\",\n \"category\": \"guideline\",\n \"tags\": [\n \"remote\",\n \"work\",\n \"guidelines\"\n ],\n \"confidentialityLevel\": \"public\"\n },\n {\n \"documentId\": \"doc-004\",\n \"title\": \"Marketing Campaign Plan 2025\",\n \"author\": \"dave.kumar\",\n \"department\": \"Marketing\",\n \"createdAt\": \"2024-08-01T08:45:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"plan\",\n \"tags\": [\n \"marketing\",\n \"campaign\",\n \"2025\"\n ],\n \"confidentialityLevel\": \"internal\"\n },\n {\n \"documentId\": \"doc-005\",\n \"title\": \"Data Privacy Regulations Overview\",\n \"author\": \"eva.martinez\",\n \"department\": \"Legal\",\n \"createdAt\": \"2024-01-10T10:20:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"regulation\",\n \"tags\": [\n \"privacy\",\n \"data\",\n \"regulation\"\n ],\n \"confidentialityLevel\": \"confidential\"\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Can you show me the latest approved policies from IT Security?\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, here are the approved IT Security policies sorted by most recent.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"Show approved policies from IT Security\",\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": [\n {\n \"term\": {\n \"status\": \"approved\"\n }\n },\n {\n \"term\": {\n \"department\": \"IT Security\"\n }\n }\n ]\n }\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n }\n]\n\nUser Query: $List PDFs from Finance department after 2024\n\nRephrased Query: List PDF documents in the Finance department created after 2024\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": [\n {\n \"term\": {\n \"fileType\": \"pdf\"\n }\n },\n {\n \"term\": {\n \"department\": \"Finance\"\n }\n },\n {\n \"range\": {\n \"createdAt\": {\n \"gte\": \"2024-01-01T00:00:00Z\"\n }\n }\n }\n ]\n }\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n}" } ]
{ "domain": "Blog Posts", "data_type": "unstructured", "query_type": "listing_with_filters", "pattern": "initial", "pattern_type": "complex_query", "size": 10, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: Supplier Contracts\n\nField Mappings:\n{\n \"properties\": {\n \"ticketId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"description\": {\n \"type\": \"text\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"priority\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"assignee\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"price\": {\n \"type\": \"float\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"ticketId\": \"SC-1001\",\n \"title\": \"Annual Supply Agreement for Office Supplies\",\n \"description\": \"Contract renewal for office stationery with Vendor A covering the fiscal year 2025.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"network\",\n \"assignee\": \"tech_support\",\n \"createdAt\": \"2025-10-01T08:15:30Z\",\n \"price\": 12500\n },\n {\n \"ticketId\": \"SC-1002\",\n \"title\": \"Hardware Procurement Contract\",\n \"description\": \"Purchase of servers and networking equipment from Vendor B.\",\n \"status\": \"closed\",\n \"priority\": \"medium\",\n \"category\": \"hardware\",\n \"assignee\": \"procurement_team\",\n \"createdAt\": \"2025-09-15T11:42:10Z\",\n \"price\": 85000\n },\n {\n \"ticketId\": \"SC-1003\",\n \"title\": \"Software License Renewal\",\n \"description\": \"Renewal of enterprise software licenses for the finance department.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"software\",\n \"assignee\": \"it_support\",\n \"createdAt\": \"2025-10-05T14:07:45Z\",\n \"price\": 42000\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Show open high-priority network tickets assigned to tech support\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, I will retrieve the tickets that match those criteria.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"List all tickets\",\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": []\n }\n },\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n }\n]\n\nUser Query: Show open high-priority network tickets assigned to tech support\n\nRephrased Query: List open tickets with high priority in the network category assigned to the tech support team\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": [\n {\n \"term\": {\n \"status\": \"open\"\n }\n },\n {\n \"term\": {\n \"priority\": \"high\"\n }\n },\n {\n \"term\": {\n \"category\": \"network\"\n }\n },\n {\n \"term\": {\n \"assignee\": \"tech_support\"\n }\n }\n ]\n }\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n}" } ]
{ "domain": "Supplier Contracts", "data_type": "structured", "query_type": "listing_with_filters", "pattern": "initial", "pattern_type": "complex_query", "size": 10, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: Legal Documents\n\nField Mappings:\n{\n \"properties\": {\n \"documentId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"author\": {\n \"type\": \"keyword\"\n },\n \"department\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"fileType\": {\n \"type\": \"keyword\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"tags\": {\n \"type\": \"keyword\"\n },\n \"confidentialityLevel\": {\n \"type\": \"keyword\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"documentId\": \"DOC-001\",\n \"title\": \"IT Security Policy\",\n \"author\": \"Alice Johnson\",\n \"department\": \"IT Security\",\n \"createdAt\": \"2023-11-15\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"policy\",\n \"tags\": [\n \"security\",\n \"policy\"\n ],\n \"confidentialityLevel\": \"internal\"\n },\n {\n \"documentId\": \"DOC-002\",\n \"title\": \"Finance Quarterly Report Q1 2024\",\n \"author\": \"Bob Martinez\",\n \"department\": \"Finance\",\n \"createdAt\": \"2024-04-10\",\n \"fileType\": \"pdf\",\n \"status\": \"draft\",\n \"category\": \"report\",\n \"tags\": [\n \"finance\",\n \"quarterly\"\n ],\n \"confidentialityLevel\": \"confidential\"\n },\n {\n \"documentId\": \"DOC-003\",\n \"title\": \"Remote Work Guidelines\",\n \"author\": \"Carol Lee\",\n \"department\": \"Human Resources\",\n \"createdAt\": \"2024-01-05\",\n \"fileType\": \"docx\",\n \"status\": \"approved\",\n \"category\": \"guideline\",\n \"tags\": [\n \"remote\",\n \"work\",\n \"policy\"\n ],\n \"confidentialityLevel\": \"public\"\n }\n]\n\nChat History:\n[]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"Show approved policies from IT Security\",\n \"dsl_type\": \"hybrid_search_with_filters\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"query\": {\n \"hybrid\": {\n \"query\": {\n \"match_all\": {}\n },\n \"filter\": {\n \"bool\": {\n \"must\": [\n {\n \"term\": {\n \"status\": \"approved\"\n }\n },\n {\n \"term\": {\n \"department\": \"IT Security\"\n }\n },\n {\n \"term\": {\n \"category\": \"policy\"\n }\n }\n ]\n }\n }\n }\n }\n }\n }\n]\n\nUser Query: List PDFs from Finance department after 2024\n\nRephrased Query: Retrieve PDF documents in the Finance department created on or after 2024-01-01\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"hybrid_search_with_filters\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"hybrid\": {\n \"query\": {\n \"match_all\": {}\n },\n \"filter\": {\n \"bool\": {\n \"must\": [\n {\n \"term\": {\n \"fileType\": \"pdf\"\n }\n },\n {\n \"term\": {\n \"department\": \"Finance\"\n }\n },\n {\n \"range\": {\n \"createdAt\": {\n \"gte\": \"2024-01-01\"\n }\n }\n }\n ]\n }\n }\n }\n }\n }\n}" } ]
{ "domain": "Legal Documents", "data_type": "unstructured", "query_type": "hybrid_search_with_filters", "pattern": "initial", "pattern_type": "filtered_search", "size": 10, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: Product Catalog\n\nField Mappings:\n{\n \"properties\": {\n \"productId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"description\": {\n \"type\": \"text\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"priority\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"assignee\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"price\": {\n \"type\": \"float\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"productId\": \"P-1001\",\n \"title\": \"Enterprise Router X200\",\n \"description\": \"High‑performance router for large networks with advanced security features.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"network\",\n \"assignee\": \"tech support\",\n \"createdAt\": \"2024-09-12T08:15:30Z\",\n \"price\": 1299.99\n },\n {\n \"productId\": \"P-1002\",\n \"title\": \"Secure VPN Appliance\",\n \"description\": \"Compact VPN device supporting up to 500 concurrent users.\",\n \"status\": \"closed\",\n \"priority\": \"medium\",\n \"category\": \"security\",\n \"assignee\": \"john.doe\",\n \"createdAt\": \"2024-08-05T14:42:10Z\",\n \"price\": 799\n },\n {\n \"productId\": \"P-1003\",\n \"title\": \"Wireless Access Point Pro\",\n \"description\": \"Dual‑band AP with PoE support and seamless roaming.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"network\",\n \"assignee\": \"tech support\",\n \"createdAt\": \"2024-09-20T11:03:45Z\",\n \"price\": 249.5\n },\n {\n \"productId\": \"P-1004\",\n \"title\": \"Data Center Switch 48‑Port\",\n \"description\": \"Layer‑2/3 switch with 48 10GbE ports and optional stacking.\",\n \"status\": \"open\",\n \"priority\": \"low\",\n \"category\": \"network\",\n \"assignee\": \"alice.smith\",\n \"createdAt\": \"2024-07-30T09:27:00Z\",\n \"price\": 2199\n },\n {\n \"productId\": \"P-1005\",\n \"title\": \"Cloud Backup Service\",\n \"description\": \"Managed backup solution with unlimited storage for enterprise clients.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"service\",\n \"assignee\": \"tech support\",\n \"createdAt\": \"2024-09-01T16:55:20Z\",\n \"price\": 149.99\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Show 10 tickets\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Here are the first 10 tickets matching your request.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"Show 10 tickets\",\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": []\n }\n }\n }\n }\n]\n\nUser Query: Show 46 open high‑priority network tickets assigned to tech support\n\nRephrased Query: Retrieve 46 tickets where status is open, priority is high, category is network, and assignee is tech support\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 46,\n \"from\": 92,\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": [\n {\n \"term\": {\n \"status\": \"open\"\n }\n },\n {\n \"term\": {\n \"priority\": \"high\"\n }\n },\n {\n \"term\": {\n \"category\": \"network\"\n }\n },\n {\n \"term\": {\n \"assignee\": \"tech support\"\n }\n }\n ]\n }\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n}" } ]
{ "domain": "Product Catalog", "data_type": "structured", "query_type": "listing_with_filters", "pattern": "pagination", "pattern_type": "more_results", "size": 46, "from": 92, "is_pagination": true }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: Research Papers\n\nField Mappings:\n{\n \"properties\": {\n \"documentId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"author\": {\n \"type\": \"keyword\"\n },\n \"department\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"fileType\": {\n \"type\": \"keyword\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"tags\": {\n \"type\": \"keyword\"\n },\n \"confidentialityLevel\": {\n \"type\": \"keyword\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"documentId\": \"RP-001\",\n \"title\": \"Security Policies for Remote Work\",\n \"author\": \"alice.smith\",\n \"department\": \"IT Security\",\n \"createdAt\": \"2024-03-15T09:30:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"policy\",\n \"tags\": [\n \"security\",\n \"remote\",\n \"policy\"\n ],\n \"confidentialityLevel\": \"internal\"\n },\n {\n \"documentId\": \"RP-002\",\n \"title\": \"Financial Reporting Guidelines 2024\",\n \"author\": \"bob.johnson\",\n \"department\": \"Finance\",\n \"createdAt\": \"2024-01-20T14:12:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"draft\",\n \"category\": \"guideline\",\n \"tags\": [\n \"finance\",\n \"reporting\"\n ],\n \"confidentialityLevel\": \"confidential\"\n },\n {\n \"documentId\": \"RP-003\",\n \"title\": \"Data Privacy Regulations Overview\",\n \"author\": \"carol.lee\",\n \"department\": \"Legal\",\n \"createdAt\": \"2023-11-05T08:45:00Z\",\n \"fileType\": \"docx\",\n \"status\": \"approved\",\n \"category\": \"regulation\",\n \"tags\": [\n \"privacy\",\n \"data\",\n \"regulation\"\n ],\n \"confidentialityLevel\": \"public\"\n },\n {\n \"documentId\": \"RP-004\",\n \"title\": \"IT Security Incident Response Plan\",\n \"author\": \"david.kim\",\n \"department\": \"IT Security\",\n \"createdAt\": \"2024-06-01T11:00:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"procedure\",\n \"tags\": [\n \"incident\",\n \"response\",\n \"security\"\n ],\n \"confidentialityLevel\": \"internal\"\n },\n {\n \"documentId\": \"RP-005\",\n \"title\": \"Remote Work Guidelines for Employees\",\n \"author\": \"emma.wilson\",\n \"department\": \"Human Resources\",\n \"createdAt\": \"2024-02-10T10:20:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"policy\",\n \"tags\": [\n \"remote\",\n \"work\",\n \"HR\"\n ],\n \"confidentialityLevel\": \"public\"\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Can you show me the latest security policies?\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, here are the most recent approved security policies.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"List 10 recent finance documents\",\n \"dsl_type\": \"simple_match\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"match\": {\n \"department\": \"Finance\"\n }\n },\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n }\n }\n }\n]\n\nUser Query: Show 22 approved policies from IT Security department\n\nRephrased Query: Retrieve 22 documents where status is approved and department is IT Security, focusing on policy category\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"hybrid_search_with_filters\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 22,\n \"from\": 0,\n \"query\": {\n \"hybrid\": {\n \"query\": \"security policies\",\n \"filter\": {\n \"bool\": {\n \"must\": [\n {\n \"term\": {\n \"status\": \"approved\"\n }\n },\n {\n \"term\": {\n \"department\": \"IT Security\"\n }\n },\n {\n \"term\": {\n \"category\": \"policy\"\n }\n }\n ]\n }\n }\n }\n }\n }\n}" } ]
{ "domain": "Research Papers", "data_type": "unstructured", "query_type": "hybrid_search_with_filters", "pattern": "initial", "pattern_type": "complex_query", "size": 22, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: Medical Records\n\nField Mappings:\n{\n \"properties\": {\n \"documentId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"author\": {\n \"type\": \"keyword\"\n },\n \"department\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"fileType\": {\n \"type\": \"keyword\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"tags\": {\n \"type\": \"keyword\"\n },\n \"confidentialityLevel\": {\n \"type\": \"keyword\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"documentId\": \"MR-001\",\n \"title\": \"Patient Admission Form\",\n \"author\": \"Dr. Alice Smith\",\n \"department\": \"Emergency\",\n \"createdAt\": \"2023-11-02T08:15:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"admission\",\n \"tags\": [\n \"patient\",\n \"admission\",\n \"emergency\"\n ],\n \"confidentialityLevel\": \"high\"\n },\n {\n \"documentId\": \"MR-002\",\n \"title\": \"Radiology Report - Chest X-Ray\",\n \"author\": \"Dr. Bob Lee\",\n \"department\": \"Radiology\",\n \"createdAt\": \"2024-01-15T14:30:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"final\",\n \"category\": \"diagnostic\",\n \"tags\": [\n \"x-ray\",\n \"chest\",\n \"radiology\"\n ],\n \"confidentialityLevel\": \"high\"\n },\n {\n \"documentId\": \"MR-003\",\n \"title\": \"Hospital Security Policy\",\n \"author\": \"IT Security Team\",\n \"department\": \"IT Security\",\n \"createdAt\": \"2024-03-10T09:00:00Z\",\n \"fileType\": \"docx\",\n \"status\": \"approved\",\n \"category\": \"policy\",\n \"tags\": [\n \"security\",\n \"policy\",\n \"access\"\n ],\n \"confidentialityLevel\": \"medium\"\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Show tickets\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, retrieving the first 10 tickets for you.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"list documents\",\n \"dsl_type\": \"match_all\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"match_all\": {}\n },\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n }\n }\n }\n]\n\nUser Query: Show tickets\n\nRephrased Query: retrieve the first set of tickets without any filters\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"hybrid_search\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"bool\": {\n \"should\": [\n {\n \"match\": {\n \"title\": {\n \"query\": \"tickets\",\n \"operator\": \"and\"\n }\n }\n },\n {\n \"knn\": {\n \"documentContentWordsChunked.embedding\": {\n \"vector\": [\n 0,\n 0,\n 0,\n 0\n ],\n \"k\": 10\n }\n }\n }\n ],\n \"minimum_should_match\": 1\n }\n }\n }\n}" } ]
{ "domain": "Medical Records", "data_type": "unstructured", "query_type": "hybrid_search", "pattern": "initial", "pattern_type": "sorted_listing", "size": 10, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: Sales Orders\n\nField Mappings:\n{\n \"properties\": {\n \"ticketId\": {\n \"type\": \"keyword\"\n },\n \"productId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"description\": {\n \"type\": \"text\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"priority\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"assignee\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"price\": {\n \"type\": \"float\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"ticketId\": \"TCK-1001\",\n \"productId\": \"PRD-2001\",\n \"title\": \"Network outage in region A\",\n \"description\": \"Customer reports complete loss of connectivity in region A.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"network\",\n \"assignee\": \"tech_support\",\n \"createdAt\": \"2025-10-20T08:15:30Z\",\n \"price\": 0,\n \"documentContentWordsChunked\": [\n {\n \"passage\": \"Network outage affecting multiple sites.\",\n \"embedding\": [\n 0,\n 0,\n 0\n ]\n }\n ]\n },\n {\n \"ticketId\": \"TCK-1002\",\n \"productId\": \"PRD-2002\",\n \"title\": \"Invoice discrepancy for order 5005\",\n \"description\": \"The billed amount does not match the quoted price.\",\n \"status\": \"resolved\",\n \"priority\": \"medium\",\n \"category\": \"billing\",\n \"assignee\": \"accounting\",\n \"createdAt\": \"2025-09-15T14:42:10Z\",\n \"price\": 1250.75,\n \"documentContentWordsChunked\": [\n {\n \"passage\": \"Customer raised a concern about invoice total.\",\n \"embedding\": [\n 0,\n 0,\n 0\n ]\n }\n ]\n },\n {\n \"ticketId\": \"TCK-1003\",\n \"productId\": \"PRD-2003\",\n \"title\": \"Request for product upgrade\",\n \"description\": \"Customer wants to upgrade from basic to premium plan.\",\n \"status\": \"in_progress\",\n \"priority\": \"low\",\n \"category\": \"account\",\n \"assignee\": \"sales_rep\",\n \"createdAt\": \"2025-11-01T09:05:45Z\",\n \"price\": 299.99,\n \"documentContentWordsChunked\": [\n {\n \"passage\": \"Upgrade request details and pricing.\",\n \"embedding\": [\n 0,\n 0,\n 0\n ]\n }\n ]\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Show open tickets\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, retrieving tickets with status open.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"List all tickets\",\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": []\n }\n },\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n }\n]\n\nUser Query: Show open tickets\n\nRephrased Query: List tickets where status is open\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": [\n {\n \"term\": {\n \"status\": \"open\"\n }\n }\n ]\n }\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n}" } ]
{ "domain": "Sales Orders", "data_type": "structured", "query_type": "listing_with_filters", "pattern": "initial", "pattern_type": "keyword_search", "size": 10, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: research_papers\n\nField Mappings:\n{\n \"properties\": {\n \"documentId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"author\": {\n \"type\": \"keyword\"\n },\n \"department\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"fileType\": {\n \"type\": \"keyword\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"tags\": {\n \"type\": \"keyword\"\n },\n \"confidentialityLevel\": {\n \"type\": \"keyword\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"documentId\": \"RP-001\",\n \"title\": \"Secure Data Transmission in Cloud Environments\",\n \"author\": \"Dr. Alice Smith\",\n \"department\": \"IT Security\",\n \"createdAt\": \"2024-03-15T10:22:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"policy\",\n \"tags\": [\n \"cloud\",\n \"encryption\",\n \"security\"\n ],\n \"confidentialityLevel\": \"internal\"\n },\n {\n \"documentId\": \"RP-002\",\n \"title\": \"Financial Forecasting Models for 2025\",\n \"author\": \"John Doe\",\n \"department\": \"Finance\",\n \"createdAt\": \"2024-07-01T08:45:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"draft\",\n \"category\": \"report\",\n \"tags\": [\n \"forecast\",\n \"2025\",\n \"economics\"\n ],\n \"confidentialityLevel\": \"confidential\"\n },\n {\n \"documentId\": \"RP-003\",\n \"title\": \"Remote Work Productivity Study\",\n \"author\": \"Dr. Emily Zhang\",\n \"department\": \"Human Resources\",\n \"createdAt\": \"2023-11-20T14:10:00Z\",\n \"fileType\": \"docx\",\n \"status\": \"approved\",\n \"category\": \"research\",\n \"tags\": [\n \"remote work\",\n \"productivity\",\n \"survey\"\n ],\n \"confidentialityLevel\": \"public\"\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"List PDFs from Finance department after 2024\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, retrieving PDF documents from Finance created after 2024.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"List PDFs from Finance department after 2024\",\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": [\n {\n \"term\": {\n \"fileType\": \"pdf\"\n }\n },\n {\n \"term\": {\n \"department\": \"Finance\"\n }\n },\n {\n \"range\": {\n \"createdAt\": {\n \"gte\": \"2024-01-01\"\n }\n }\n }\n ]\n }\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n }\n]\n\nUser Query: Show approved policies from IT Security\n\nRephrased Query: List approved policy documents in the IT Security department\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": [\n {\n \"term\": {\n \"status\": \"approved\"\n }\n },\n {\n \"term\": {\n \"category\": \"policy\"\n }\n },\n {\n \"term\": {\n \"department\": \"IT Security\"\n }\n }\n ]\n }\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n}" } ]
{ "domain": "research_papers", "data_type": "unstructured", "query_type": "listing_with_filters", "pattern": "initial", "pattern_type": "complex_query", "size": 10, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: Medical Records\n\nField Mappings:\n{\n \"properties\": {\n \"documentId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"author\": {\n \"type\": \"keyword\"\n },\n \"department\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"fileType\": {\n \"type\": \"keyword\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"tags\": {\n \"type\": \"keyword\"\n },\n \"confidentialityLevel\": {\n \"type\": \"keyword\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"documentId\": \"MR-001\",\n \"title\": \"Cardiology Patient Summary\",\n \"author\": \"Dr. Alice Smith\",\n \"department\": \"Cardiology\",\n \"createdAt\": \"2023-11-20T09:15:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"patient_summary\",\n \"tags\": [\n \"heart\",\n \"echocardiogram\"\n ],\n \"confidentialityLevel\": \"high\"\n },\n {\n \"documentId\": \"MR-002\",\n \"title\": \"Radiology Imaging Report\",\n \"author\": \"Dr. Bob Lee\",\n \"department\": \"Radiology\",\n \"createdAt\": \"2024-02-05T14:30:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"pending\",\n \"category\": \"imaging_report\",\n \"tags\": [\n \"xray\",\n \"chest\"\n ],\n \"confidentialityLevel\": \"medium\"\n },\n {\n \"documentId\": \"MR-003\",\n \"title\": \"Finance Department Budget 2024\",\n \"author\": \"Catherine Green\",\n \"department\": \"Finance\",\n \"createdAt\": \"2024-01-15T08:00:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"budget\",\n \"tags\": [\n \"budget\",\n \"2024\"\n ],\n \"confidentialityLevel\": \"low\"\n },\n {\n \"documentId\": \"MR-004\",\n \"title\": \"IT Security Policy Update\",\n \"author\": \"David Kim\",\n \"department\": \"IT Security\",\n \"createdAt\": \"2024-03-10T11:45:00Z\",\n \"fileType\": \"docx\",\n \"status\": \"approved\",\n \"category\": \"policy\",\n \"tags\": [\n \"security\",\n \"policy\"\n ],\n \"confidentialityLevel\": \"high\"\n },\n {\n \"documentId\": \"MR-005\",\n \"title\": \"Oncology Treatment Guidelines\",\n \"author\": \"Dr. Emily Zhou\",\n \"department\": \"Oncology\",\n \"createdAt\": \"2023-12-01T10:20:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"guidelines\",\n \"tags\": [\n \"chemotherapy\",\n \"protocol\"\n ],\n \"confidentialityLevel\": \"high\"\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Show me the latest approved policies from IT Security.\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, here are the most recent approved IT Security policies.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"Show 10 recent approved policies\",\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": [\n {\n \"term\": {\n \"status\": \"approved\"\n }\n },\n {\n \"term\": {\n \"category\": \"policy\"\n }\n }\n ]\n }\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n }\n]\n\nUser Query: List 15 PDFs from Finance department after 2024\n\nRephrased Query: Retrieve 15 PDF documents where department is Finance and createdAt is after 2024-01-01\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 15,\n \"from\": 0,\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": [\n {\n \"term\": {\n \"fileType\": \"pdf\"\n }\n },\n {\n \"term\": {\n \"department\": \"Finance\"\n }\n },\n {\n \"range\": {\n \"createdAt\": {\n \"gte\": \"2024-01-01\"\n }\n }\n }\n ]\n }\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n}" } ]
{ "domain": "Medical Records", "data_type": "unstructured", "query_type": "listing_with_filters", "pattern": "initial", "pattern_type": "keyword_search", "size": 15, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: Inventory Items\n\nField Mappings:\n{\n \"properties\": {\n \"ticketId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"description\": {\n \"type\": \"text\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"priority\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"assignee\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"price\": {\n \"type\": \"float\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"ticketId\": \"TCK-1001\",\n \"title\": \"Network latency issue\",\n \"description\": \"Users experience high latency on the corporate VPN.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"network\",\n \"assignee\": \"tech_support\",\n \"createdAt\": \"2025-10-20T08:15:30Z\",\n \"price\": 0\n },\n {\n \"ticketId\": \"TCK-1002\",\n \"title\": \"Printer malfunction\",\n \"description\": \"Office printer prints blank pages intermittently.\",\n \"status\": \"closed\",\n \"priority\": \"low\",\n \"category\": \"hardware\",\n \"assignee\": \"maintenance\",\n \"createdAt\": \"2025-09-12T14:42:10Z\",\n \"price\": 0\n },\n {\n \"ticketId\": \"TCK-1003\",\n \"title\": \"Software license renewal\",\n \"description\": \"Renewal needed for design software before end of month.\",\n \"status\": \"open\",\n \"priority\": \"medium\",\n \"category\": \"software\",\n \"assignee\": \"procurement\",\n \"createdAt\": \"2025-10-05T11:03:45Z\",\n \"price\": 1200\n },\n {\n \"ticketId\": \"TCK-1004\",\n \"title\": \"Server disk space low\",\n \"description\": \"Primary DB server running out of disk space.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"infrastructure\",\n \"assignee\": \"tech_support\",\n \"createdAt\": \"2025-10-22T09:27:00Z\",\n \"price\": 0\n },\n {\n \"ticketId\": \"TCK-1005\",\n \"title\": \"Email phishing attempt\",\n \"description\": \"Multiple users reported suspicious emails.\",\n \"status\": \"resolved\",\n \"priority\": \"high\",\n \"category\": \"security\",\n \"assignee\": \"it_security\",\n \"createdAt\": \"2025-09-30T16:58:20Z\",\n \"price\": 0\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Show open tickets\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Here are the open tickets in the system.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"Show all tickets\",\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": []\n }\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n }\n]\n\nUser Query: Show open high-priority network tickets assigned to tech support\n\nRephrased Query: List open tickets with priority high, category network, and assignee tech_support\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": [\n {\n \"term\": {\n \"status\": \"open\"\n }\n },\n {\n \"term\": {\n \"priority\": \"high\"\n }\n },\n {\n \"term\": {\n \"category\": \"network\"\n }\n },\n {\n \"term\": {\n \"assignee\": \"tech_support\"\n }\n }\n ]\n }\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n}" } ]
{ "domain": "Inventory Items", "data_type": "structured", "query_type": "listing_with_filters", "pattern": "initial", "pattern_type": "sorted_listing", "size": 10, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: Technical Manuals\n\nField Mappings:\n{\n \"properties\": {\n \"documentId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"author\": {\n \"type\": \"keyword\"\n },\n \"department\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"fileType\": {\n \"type\": \"keyword\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"tags\": {\n \"type\": \"keyword\"\n },\n \"confidentialityLevel\": {\n \"type\": \"keyword\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"documentId\": \"TM-001\",\n \"title\": \"IT Security Policy Overview\",\n \"author\": \"alice.smith\",\n \"department\": \"IT Security\",\n \"createdAt\": \"2023-11-15T09:30:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"policy\",\n \"tags\": [\n \"security\",\n \"policy\",\n \"overview\"\n ],\n \"confidentialityLevel\": \"internal\"\n },\n {\n \"documentId\": \"TM-002\",\n \"title\": \"Finance Department Expense Guidelines\",\n \"author\": \"bob.johnson\",\n \"department\": \"Finance\",\n \"createdAt\": \"2024-02-20T14:12:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"draft\",\n \"category\": \"guideline\",\n \"tags\": [\n \"expense\",\n \"finance\",\n \"guidelines\"\n ],\n \"confidentialityLevel\": \"confidential\"\n },\n {\n \"documentId\": \"TM-003\",\n \"title\": \"Remote Work Security Checklist\",\n \"author\": \"carol.lee\",\n \"department\": \"IT Security\",\n \"createdAt\": \"2024-07-05T08:45:00Z\",\n \"fileType\": \"docx\",\n \"status\": \"approved\",\n \"category\": \"checklist\",\n \"tags\": [\n \"remote\",\n \"security\",\n \"checklist\"\n ],\n \"confidentialityLevel\": \"public\"\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Can you list the approved policies from the IT Security department?\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, I will retrieve the approved policy documents belonging to the IT Security department.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"Find PDF manuals about safety\",\n \"dsl_type\": \"semantic_search\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"semantic\": {\n \"query\": \"safety\",\n \"field\": \"documentContentWordsChunked.embedding\",\n \"filter\": {\n \"term\": {\n \"fileType\": \"pdf\"\n }\n }\n }\n }\n }\n }\n]\n\nUser Query: Show approved policies from IT Security\n\nRephrased Query: List approved policy documents from the IT Security department\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"hybrid_search_with_filters\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"hybrid\": {\n \"query\": \"approved policies\",\n \"embedder\": {\n \"field\": \"documentContentWordsChunked.embedding\"\n },\n \"filter\": {\n \"bool\": {\n \"must\": [\n {\n \"term\": {\n \"status\": \"approved\"\n }\n },\n {\n \"term\": {\n \"department\": \"IT Security\"\n }\n }\n ]\n }\n }\n }\n }\n }\n}" } ]
{ "domain": "Technical Manuals", "data_type": "unstructured", "query_type": "hybrid_search_with_filters", "pattern": "initial", "pattern_type": "complex_query", "size": 10, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: Marketing Campaigns\n\nField Mappings:\n{\n \"properties\": {\n \"ticketId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"description\": {\n \"type\": \"text\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"priority\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"assignee\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"price\": {\n \"type\": \"float\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"ticketId\": \"MKT-001\",\n \"title\": \"Spring Sale Campaign Launch\",\n \"description\": \"Prepare assets and schedule for the spring sale across all channels.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"campaign\",\n \"assignee\": \"john.doe\",\n \"createdAt\": \"2025-10-01T08:15:00Z\",\n \"price\": 1500,\n \"documentContentWordsChunked\": [\n {\n \"passage\": \"Launch the spring sale campaign with a 20% discount.\",\n \"embedding\": [\n 0,\n 0,\n 0\n ]\n }\n ]\n },\n {\n \"ticketId\": \"MKT-002\",\n \"title\": \"Email Newsletter Q4\",\n \"description\": \"Design and send the Q4 newsletter to the subscriber list.\",\n \"status\": \"in_progress\",\n \"priority\": \"medium\",\n \"category\": \"email\",\n \"assignee\": \"jane.smith\",\n \"createdAt\": \"2025-09-20T11:30:00Z\",\n \"price\": 800,\n \"documentContentWordsChunked\": [\n {\n \"passage\": \"Include new product releases and holiday promotions.\",\n \"embedding\": [\n 0,\n 0,\n 0\n ]\n }\n ]\n },\n {\n \"ticketId\": \"MKT-003\",\n \"title\": \"Social Media Ads Review\",\n \"description\": \"Review performance of paid social media ads for the last month.\",\n \"status\": \"resolved\",\n \"priority\": \"low\",\n \"category\": \"ads\",\n \"assignee\": \"john.doe\",\n \"createdAt\": \"2025-08-15T14:45:00Z\",\n \"price\": 500,\n \"documentContentWordsChunked\": [\n {\n \"passage\": \"CTR improved by 12% compared to previous period.\",\n \"embedding\": [\n 0,\n 0,\n 0\n ]\n }\n ]\n }\n]\n\nChat History:\n[]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"List all tickets\",\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": []\n }\n },\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n }\n]\n\nUser Query: Show open high-priority tickets assigned to John\n\nRephrased Query: List open tickets with high priority assigned to john.doe\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": [\n {\n \"term\": {\n \"status\": \"open\"\n }\n },\n {\n \"term\": {\n \"priority\": \"high\"\n }\n },\n {\n \"term\": {\n \"assignee\": \"john.doe\"\n }\n }\n ]\n }\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n}" } ]
{ "domain": "Marketing Campaigns", "data_type": "structured", "query_type": "listing_with_filters", "pattern": "initial", "pattern_type": "categorical_listing", "size": 10, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: News Articles\n\nField Mappings:\n{\n \"properties\": {\n \"documentId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"author\": {\n \"type\": \"keyword\"\n },\n \"department\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"fileType\": {\n \"type\": \"keyword\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"tags\": {\n \"type\": \"keyword\"\n },\n \"confidentialityLevel\": {\n \"type\": \"keyword\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n },\n \"documentContentWords\": {\n \"type\": \"text\"\n }\n }\n}\n\nSample Documents:\n[\n {\n \"documentId\": \"doc-001\",\n \"title\": \"IT Security Policy Update 2024\",\n \"author\": \"Alice Johnson\",\n \"department\": \"IT Security\",\n \"createdAt\": \"2024-02-15T09:30:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"policy\",\n \"tags\": [\n \"security\",\n \"policy\",\n \"update\"\n ],\n \"confidentialityLevel\": \"internal\"\n },\n {\n \"documentId\": \"doc-002\",\n \"title\": \"Remote Work Guidelines\",\n \"author\": \"Bob Smith\",\n \"department\": \"Human Resources\",\n \"createdAt\": \"2024-01-10T14:20:00Z\",\n \"fileType\": \"docx\",\n \"status\": \"draft\",\n \"category\": \"guideline\",\n \"tags\": [\n \"remote\",\n \"work\",\n \"policy\"\n ],\n \"confidentialityLevel\": \"public\"\n },\n {\n \"documentId\": \"doc-003\",\n \"title\": \"Finance Department Quarterly Report Q1 2024\",\n \"author\": \"Carol Lee\",\n \"department\": \"Finance\",\n \"createdAt\": \"2024-04-05T11:00:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"report\",\n \"tags\": [\n \"finance\",\n \"quarterly\",\n \"report\"\n ],\n \"confidentialityLevel\": \"confidential\"\n },\n {\n \"documentId\": \"doc-004\",\n \"title\": \"Data Privacy Regulations Overview\",\n \"author\": \"David Kim\",\n \"department\": \"Legal\",\n \"createdAt\": \"2023-12-20T08:45:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"regulation\",\n \"tags\": [\n \"privacy\",\n \"data\",\n \"regulation\"\n ],\n \"confidentialityLevel\": \"internal\"\n },\n {\n \"documentId\": \"doc-005\",\n \"title\": \"IT Security Incident Response Plan\",\n \"author\": \"Evelyn Martinez\",\n \"department\": \"IT Security\",\n \"createdAt\": \"2024-03-01T10:15:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"plan\",\n \"tags\": [\n \"incident\",\n \"response\",\n \"security\"\n ],\n \"confidentialityLevel\": \"confidential\"\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Can you list the latest security policies?\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, here are the most recent security policies...\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"list 10 recent articles\",\n \"dsl_type\": \"simple_search\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"match_all\": {}\n }\n }\n }\n]\n\nUser Query: Show 38 approved policies from IT Security department\n\nRephrased Query: Retrieve 38 documents where status is approved and department is IT Security\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"hybrid_search_with_filters\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 38,\n \"from\": 0,\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"text_embedding\": {\n \"field\": \"documentContentWordsChunked.embedding\",\n \"query_vector\": [\n 0.1,\n 0.2,\n 0.3\n ],\n \"k\": 38\n }\n },\n {\n \"match\": {\n \"title\": \"policy\"\n }\n }\n ],\n \"filter\": {\n \"bool\": {\n \"must\": [\n {\n \"term\": {\n \"status\": \"approved\"\n }\n },\n {\n \"term\": {\n \"department\": \"IT Security\"\n }\n }\n ]\n }\n }\n }\n }\n }\n}" } ]
{ "domain": "News Articles", "data_type": "unstructured", "query_type": "hybrid_search_with_filters", "pattern": "initial", "pattern_type": "sorted_listing", "size": 38, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: Customer Support Tickets\n\nField Mappings:\n{\n \"properties\": {\n \"ticketId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"description\": {\n \"type\": \"text\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"priority\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"assignee\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"price\": {\n \"type\": \"float\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"ticketId\": \"TCKT-001\",\n \"title\": \"Network outage in building A\",\n \"description\": \"Users report loss of connectivity on floor 3. Immediate investigation required.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"network\",\n \"assignee\": \"tech support\",\n \"createdAt\": \"2025-10-20T08:15:30Z\",\n \"price\": 0\n },\n {\n \"ticketId\": \"TCKT-002\",\n \"title\": \"Billing discrepancy for account 4521\",\n \"description\": \"Customer was overcharged for the month of September.\",\n \"status\": \"resolved\",\n \"priority\": \"medium\",\n \"category\": \"billing\",\n \"assignee\": \"finance team\",\n \"createdAt\": \"2025-09-28T14:42:10Z\",\n \"price\": 150.75\n },\n {\n \"ticketId\": \"TCKT-003\",\n \"title\": \"Software installation request\",\n \"description\": \"Request to install the latest version of the analytics tool on workstation 12.\",\n \"status\": \"in_progress\",\n \"priority\": \"low\",\n \"category\": \"software\",\n \"assignee\": \"it support\",\n \"createdAt\": \"2025-11-01T09:05:00Z\",\n \"price\": 0\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Show tickets\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Here are the latest tickets in the system.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"Show tickets\",\n \"dsl_type\": \"listing\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"match_all\": {}\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n }\n]\n\nUser Query: List high-priority network tickets assigned to tech support\n\nRephrased Query: Retrieve tickets with priority high, category network, and assignee tech support\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": [\n {\n \"term\": {\n \"priority\": \"high\"\n }\n },\n {\n \"term\": {\n \"category\": \"network\"\n }\n },\n {\n \"term\": {\n \"assignee\": \"tech support\"\n }\n },\n {\n \"term\": {\n \"status\": \"open\"\n }\n }\n ]\n }\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n}" } ]
{ "domain": "Customer Support Tickets", "data_type": "structured", "query_type": "listing_with_filters", "pattern": "initial", "pattern_type": "complex_query", "size": 10, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: Product Catalog\n\nField Mappings:\n{\n \"properties\": {\n \"productId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"description\": {\n \"type\": \"text\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"priority\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"assignee\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"price\": {\n \"type\": \"float\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"productId\": \"P-1001\",\n \"title\": \"Enterprise Network Router\",\n \"description\": \"High‑performance router for large scale enterprise networks.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"network\",\n \"assignee\": \"tech_support\",\n \"createdAt\": \"2024-10-12T08:15:30Z\",\n \"price\": 1299.99,\n \"documentContentWordsChunked\": []\n },\n {\n \"productId\": \"P-1002\",\n \"title\": \"Secure VPN Appliance\",\n \"description\": \"Appliance providing secure site‑to‑site VPN connections.\",\n \"status\": \"closed\",\n \"priority\": \"medium\",\n \"category\": \"security\",\n \"assignee\": \"security_team\",\n \"createdAt\": \"2024-09-05T14:42:10Z\",\n \"price\": 799.5,\n \"documentContentWordsChunked\": []\n },\n {\n \"productId\": \"P-1003\",\n \"title\": \"Wireless Access Point\",\n \"description\": \"Dual‑band Wi‑Fi 6 access point for office environments.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"network\",\n \"assignee\": \"tech_support\",\n \"createdAt\": \"2024-11-01T11:03:45Z\",\n \"price\": 249,\n \"documentContentWordsChunked\": []\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Can you show me the open tickets for the network category?\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, here are the open network tickets.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"list 10 tickets\",\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": []\n }\n }\n }\n }\n]\n\nUser Query: Show me 16 open high‑priority network tickets assigned to tech support\n\nRephrased Query: Retrieve 16 tickets where status is open, priority is high, category is network, and assignee is tech_support\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 16,\n \"from\": 0,\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": [\n {\n \"term\": {\n \"status\": \"open\"\n }\n },\n {\n \"term\": {\n \"priority\": \"high\"\n }\n },\n {\n \"term\": {\n \"category\": \"network\"\n }\n },\n {\n \"term\": {\n \"assignee\": \"tech_support\"\n }\n }\n ]\n }\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n}" } ]
{ "domain": "Product Catalog", "data_type": "structured", "query_type": "listing_with_filters", "pattern": "initial", "pattern_type": "sorted_listing", "size": 16, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: IT Support Tickets\n\nField Mappings:\n{\n \"properties\": {\n \"ticketId\": {\n \"type\": \"keyword\"\n },\n \"productId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"description\": {\n \"type\": \"text\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"priority\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"assignee\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"price\": {\n \"type\": \"float\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"ticketId\": \"TCK-1001\",\n \"productId\": \"PRD-200\",\n \"title\": \"Unable to connect to VPN\",\n \"description\": \"User reports that the VPN client fails to establish a connection after the recent update.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"network\",\n \"assignee\": \"tech_support_01\",\n \"createdAt\": \"2025-10-28T09:15:00Z\",\n \"price\": 0\n },\n {\n \"ticketId\": \"TCK-1002\",\n \"productId\": \"PRD-305\",\n \"title\": \"Email sync errors on mobile device\",\n \"description\": \"Emails are not syncing on iOS devices for several users in the sales department.\",\n \"status\": \"in_progress\",\n \"priority\": \"medium\",\n \"category\": \"email\",\n \"assignee\": \"tech_support_02\",\n \"createdAt\": \"2025-10-27T14:42:00Z\",\n \"price\": 0\n },\n {\n \"ticketId\": \"TCK-1003\",\n \"productId\": \"PRD-410\",\n \"title\": \"Printer driver crash on Windows 11\",\n \"description\": \"The latest printer driver causes system crashes when printing large PDFs.\",\n \"status\": \"resolved\",\n \"priority\": \"low\",\n \"category\": \"hardware\",\n \"assignee\": \"tech_support_03\",\n \"createdAt\": \"2025-10-25T08:30:00Z\",\n \"price\": 0\n },\n {\n \"ticketId\": \"TCK-1004\",\n \"productId\": \"PRD-120\",\n \"title\": \"Password reset request for admin account\",\n \"description\": \"Admin user cannot log in after password expiration; needs immediate reset.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"account\",\n \"assignee\": \"tech_support_01\",\n \"createdAt\": \"2025-10-29T11:05:00Z\",\n \"price\": 0\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Can you show me the most recent tickets?\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, here's a list of the latest tickets sorted by creation date.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"Show me 10 tickets\",\n \"dsl_type\": \"listing\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"match_all\": {}\n }\n }\n }\n]\n\nUser Query: Show me 25 tickets\n\nRephrased Query: list 25 tickets without any filters\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"listing\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 25,\n \"from\": 0,\n \"query\": {\n \"match_all\": {}\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n}" } ]
{ "domain": "IT Support Tickets", "data_type": "structured", "query_type": "listing", "pattern": "initial", "pattern_type": "keyword_search", "size": 25, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: Product Reviews\n\nField Mappings:\n{\n \"properties\": {\n \"documentId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"author\": {\n \"type\": \"keyword\"\n },\n \"department\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"fileType\": {\n \"type\": \"keyword\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"tags\": {\n \"type\": \"keyword\"\n },\n \"confidentialityLevel\": {\n \"type\": \"keyword\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"documentId\": \"doc_001\",\n \"title\": \"Wireless Earbuds Review\",\n \"author\": \"alice.smith\",\n \"department\": \"Consumer Electronics\",\n \"createdAt\": \"2024-03-12T09:15:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"Audio\",\n \"tags\": [\n \"wireless\",\n \"earbuds\",\n \"battery life\"\n ],\n \"confidentialityLevel\": \"public\"\n },\n {\n \"documentId\": \"doc_002\",\n \"title\": \"Smartphone Camera Comparison\",\n \"author\": \"bob.jones\",\n \"department\": \"Mobile Devices\",\n \"createdAt\": \"2024-06-05T14:30:00Z\",\n \"fileType\": \"docx\",\n \"status\": \"draft\",\n \"category\": \"Photography\",\n \"tags\": [\n \"camera\",\n \"resolution\",\n \"low light\"\n ],\n \"confidentialityLevel\": \"internal\"\n },\n {\n \"documentId\": \"doc_003\",\n \"title\": \"Laptop Battery Longevity Test\",\n \"author\": \"carla.lee\",\n \"department\": \"Computing\",\n \"createdAt\": \"2024-01-20T11:45:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"Performance\",\n \"tags\": [\n \"battery\",\n \"runtime\",\n \"stress test\"\n ],\n \"confidentialityLevel\": \"public\"\n },\n {\n \"documentId\": \"doc_004\",\n \"title\": \"Smartwatch Feature Overview\",\n \"author\": \"david.kim\",\n \"department\": \"Wearables\",\n \"createdAt\": \"2024-08-02T08:00:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"Health\",\n \"tags\": [\n \"heart rate\",\n \"notifications\",\n \"battery\"\n ],\n \"confidentialityLevel\": \"public\"\n },\n {\n \"documentId\": \"doc_005\",\n \"title\": \"Gaming Console Performance Review\",\n \"author\": \"emma.wong\",\n \"department\": \"Gaming\",\n \"createdAt\": \"2024-04-18T16:20:00Z\",\n \"fileType\": \"docx\",\n \"status\": \"approved\",\n \"category\": \"Performance\",\n \"tags\": [\n \"fps\",\n \"graphics\",\n \"load times\"\n ],\n \"confidentialityLevel\": \"internal\"\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Show tickets\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, retrieving the latest tickets for you.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"List recent tickets\",\n \"dsl_type\": \"listing\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"match_all\": {}\n }\n }\n }\n]\n\nUser Query: Show tickets\n\nRephrased Query: List recent tickets without any filters\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"listing\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"match_all\": {}\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n}" } ]
{ "domain": "Product Reviews", "data_type": "unstructured", "query_type": "listing", "pattern": "pagination", "pattern_type": "previous_page", "size": 10, "from": 0, "is_pagination": true }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: Inventory Tickets\n\nField Mappings:\n{\n \"properties\": {\n \"ticketId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"description\": {\n \"type\": \"text\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"priority\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"assignee\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"price\": {\n \"type\": \"float\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"ticketId\": \"TCK-1001\",\n \"title\": \"Network latency issue\",\n \"description\": \"Users experiencing high latency on VPN connections.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"network\",\n \"assignee\": \"tech_support\",\n \"createdAt\": \"2025-10-20T08:15:30Z\",\n \"price\": 0\n },\n {\n \"ticketId\": \"TCK-1002\",\n \"title\": \"Printer malfunction\",\n \"description\": \"Office printer prints blank pages intermittently.\",\n \"status\": \"resolved\",\n \"priority\": \"medium\",\n \"category\": \"hardware\",\n \"assignee\": \"field_engineer\",\n \"createdAt\": \"2025-09-12T14:42:10Z\",\n \"price\": 0\n },\n {\n \"ticketId\": \"TCK-1003\",\n \"title\": \"Software license renewal\",\n \"description\": \"Renewal required for design software before end of month.\",\n \"status\": \"in_progress\",\n \"priority\": \"low\",\n \"category\": \"software\",\n \"assignee\": \"procurement\",\n \"createdAt\": \"2025-11-01T09:00:00Z\",\n \"price\": 1200\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"List high‑priority network tickets assigned to tech support\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, retrieving tickets with priority high, category network, and assignee tech_support.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"List all tickets\",\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": []\n }\n },\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n }\n]\n\nUser Query: Show open tickets\n\nRephrased Query: List tickets where status is open\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": [\n {\n \"term\": {\n \"status\": \"open\"\n }\n }\n ]\n }\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n}" } ]
{ "domain": "Inventory Tickets", "data_type": "structured", "query_type": "listing_with_filters", "pattern": "initial", "pattern_type": "categorical_listing", "size": 10, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: Sales Orders\n\nField Mappings:\n{\n \"properties\": {\n \"ticketId\": {\n \"type\": \"keyword\"\n },\n \"productId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"description\": {\n \"type\": \"text\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"priority\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"assignee\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"price\": {\n \"type\": \"float\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"ticketId\": \"SO-1001\",\n \"productId\": \"PR-2001\",\n \"title\": \"Network latency issue\",\n \"description\": \"Customer reports intermittent latency on VPN connections.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"network\",\n \"assignee\": \"tech_support\",\n \"createdAt\": \"2024-10-12T08:15:30Z\",\n \"price\": 1250,\n \"documentContentWordsChunked\": [\n {\n \"passage\": \"Network latency issue details...\",\n \"embedding\": [\n 0,\n 0,\n 0\n ]\n }\n ]\n },\n {\n \"ticketId\": \"SO-1002\",\n \"productId\": \"PR-2002\",\n \"title\": \"Invoice discrepancy\",\n \"description\": \"Invoice amount does not match the quoted price.\",\n \"status\": \"closed\",\n \"priority\": \"medium\",\n \"category\": \"billing\",\n \"assignee\": \"accounting\",\n \"createdAt\": \"2024-09-28T14:42:10Z\",\n \"price\": 980.5,\n \"documentContentWordsChunked\": [\n {\n \"passage\": \"Invoice discrepancy details...\",\n \"embedding\": [\n 0,\n 0,\n 0\n ]\n }\n ]\n },\n {\n \"ticketId\": \"SO-1003\",\n \"productId\": \"PR-2003\",\n \"title\": \"Hardware replacement request\",\n \"description\": \"Customer requests replacement of faulty router.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"network\",\n \"assignee\": \"tech_support\",\n \"createdAt\": \"2024-10-05T11:20:45Z\",\n \"price\": 450.75,\n \"documentContentWordsChunked\": [\n {\n \"passage\": \"Hardware replacement request details...\",\n \"embedding\": [\n 0,\n 0,\n 0\n ]\n }\n ]\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Show 17 open high-priority network tickets\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, I will retrieve the 17 tickets that match those criteria.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"Show 10 tickets\",\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": []\n }\n },\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n }\n]\n\nUser Query: Show 17 open high-priority network tickets\n\nRephrased Query: List 17 tickets where status is open, priority is high, and category is network\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 17,\n \"from\": 0,\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": [\n {\n \"term\": {\n \"status\": \"open\"\n }\n },\n {\n \"term\": {\n \"priority\": \"high\"\n }\n },\n {\n \"term\": {\n \"category\": \"network\"\n }\n }\n ]\n }\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n}" } ]
{ "domain": "Sales Orders", "data_type": "structured", "query_type": "listing_with_filters", "pattern": "initial", "pattern_type": "semantic_question", "size": 17, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: Product Reviews\n\nField Mappings:\n{\n \"properties\": {\n \"documentId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"author\": {\n \"type\": \"keyword\"\n },\n \"department\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"fileType\": {\n \"type\": \"keyword\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"tags\": {\n \"type\": \"keyword\"\n },\n \"confidentialityLevel\": {\n \"type\": \"keyword\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"documentId\": \"doc-001\",\n \"title\": \"Q1 Financial Review\",\n \"author\": \"alice.smith\",\n \"department\": \"Finance\",\n \"createdAt\": \"2024-02-15T10:30:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"report\",\n \"tags\": [\n \"Q1\",\n \"financial\",\n \"summary\"\n ],\n \"confidentialityLevel\": \"internal\"\n },\n {\n \"documentId\": \"doc-002\",\n \"title\": \"Employee Satisfaction Survey Results\",\n \"author\": \"bob.jones\",\n \"department\": \"HR\",\n \"createdAt\": \"2023-11-20T08:00:00Z\",\n \"fileType\": \"docx\",\n \"status\": \"draft\",\n \"category\": \"survey\",\n \"tags\": [\n \"employee\",\n \"satisfaction\"\n ],\n \"confidentialityLevel\": \"restricted\"\n },\n {\n \"documentId\": \"doc-003\",\n \"title\": \"Product X User Feedback\",\n \"author\": \"carla.lee\",\n \"department\": \"Product\",\n \"createdAt\": \"2024-05-05T14:45:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"review\",\n \"tags\": [\n \"productX\",\n \"feedback\"\n ],\n \"confidentialityLevel\": \"public\"\n },\n {\n \"documentId\": \"doc-004\",\n \"title\": \"IT Security Policy Update\",\n \"author\": \"david.kim\",\n \"department\": \"IT Security\",\n \"createdAt\": \"2024-01-10T09:15:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"policy\",\n \"tags\": [\n \"security\",\n \"policy\",\n \"update\"\n ],\n \"confidentialityLevel\": \"confidential\"\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Show approved policies from IT Security\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Here are the approved IT Security policies...\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"Show approved policies from IT Security\",\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": [\n {\n \"term\": {\n \"department\": \"IT Security\"\n }\n },\n {\n \"term\": {\n \"status\": \"approved\"\n }\n }\n ]\n }\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n }\n]\n\nUser Query: $List PDFs from Finance department after 2024\n\nRephrased Query: List PDF documents from the Finance department created after 2024\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": [\n {\n \"term\": {\n \"fileType\": \"pdf\"\n }\n },\n {\n \"term\": {\n \"department\": \"Finance\"\n }\n },\n {\n \"range\": {\n \"createdAt\": {\n \"gte\": \"2024-01-01\"\n }\n }\n }\n ]\n }\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n}" } ]
{ "domain": "Product Reviews", "data_type": "unstructured", "query_type": "listing_with_filters", "pattern": "initial", "pattern_type": "categorical_listing", "size": 10, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: Research Papers\n\nField Mappings:\n{\n \"properties\": {\n \"documentId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"author\": {\n \"type\": \"text\"\n },\n \"department\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"fileType\": {\n \"type\": \"keyword\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"tags\": {\n \"type\": \"keyword\"\n },\n \"confidentialityLevel\": {\n \"type\": \"keyword\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"documentId\": \"RP-001\",\n \"title\": \"Advances in Quantum Computing\",\n \"author\": \"Dr. Alice Nguyen\",\n \"department\": \"Physics\",\n \"createdAt\": \"2023-05-12T09:30:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"research\",\n \"tags\": [\n \"quantum\",\n \"computing\",\n \"algorithm\"\n ],\n \"confidentialityLevel\": \"public\"\n },\n {\n \"documentId\": \"RP-002\",\n \"title\": \"Machine Learning for Healthcare\",\n \"author\": \"Prof. Brian Lee\",\n \"department\": \"Computer Science\",\n \"createdAt\": \"2024-01-20T14:15:00Z\",\n \"fileType\": \"docx\",\n \"status\": \"draft\",\n \"category\": \"research\",\n \"tags\": [\n \"machine learning\",\n \"healthcare\",\n \"data\"\n ],\n \"confidentialityLevel\": \"internal\"\n },\n {\n \"documentId\": \"RP-003\",\n \"title\": \"Renewable Energy Policy Overview\",\n \"author\": \"Dr. Carla Mendes\",\n \"department\": \"Environmental Studies\",\n \"createdAt\": \"2022-11-03T08:00:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"policy\",\n \"tags\": [\n \"renewable\",\n \"energy\",\n \"policy\"\n ],\n \"confidentialityLevel\": \"public\"\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Show tickets\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Here are the first 10 tickets from the system.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"list documents\",\n \"dsl_type\": \"hybrid_search\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"match_all\": {}\n }\n }\n }\n]\n\nUser Query: Show tickets\n\nRephrased Query: List the first ten tickets\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"hybrid_search\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"match_all\": {}\n }\n }\n}" } ]
{ "domain": "Research Papers", "data_type": "unstructured", "query_type": "hybrid_search", "pattern": "initial", "pattern_type": "filtered_search", "size": 10, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: Financial Transactions\n\nField Mappings:\n{\n \"properties\": {\n \"ticketId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"description\": {\n \"type\": \"text\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"priority\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"assignee\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"price\": {\n \"type\": \"double\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"ticketId\": \"TXN-1001\",\n \"title\": \"Payment reversal request\",\n \"description\": \"Customer requested reversal of a $5,000 payment due to duplicate transaction.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"payment\",\n \"assignee\": \"finance_team\",\n \"createdAt\": \"2025-10-20T09:15:00Z\",\n \"price\": 5000\n },\n {\n \"ticketId\": \"TXN-1002\",\n \"title\": \"Invoice discrepancy\",\n \"description\": \"Invoice #INV-2025-045 shows an overcharge of $250 on the service fee.\",\n \"status\": \"in_progress\",\n \"priority\": \"medium\",\n \"category\": \"billing\",\n \"assignee\": \"accounting\",\n \"createdAt\": \"2025-10-18T14:42:00Z\",\n \"price\": 250\n },\n {\n \"ticketId\": \"TXN-1003\",\n \"title\": \"Failed wire transfer\",\n \"description\": \"Wire transfer to vendor failed with error code 502; amount $12,300.\",\n \"status\": \"resolved\",\n \"priority\": \"high\",\n \"category\": \"transfer\",\n \"assignee\": \"finance_team\",\n \"createdAt\": \"2025-09-30T08:05:00Z\",\n \"price\": 12300\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"List all tickets\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, here are the latest tickets across all categories.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"List all tickets\",\n \"dsl_type\": \"listing\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"match_all\": {}\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n }\n]\n\nUser Query: Show open tickets assigned to finance team\n\nRephrased Query: List open tickets where status is open and assignee is finance_team\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": [\n {\n \"term\": {\n \"status\": \"open\"\n }\n },\n {\n \"term\": {\n \"assignee\": \"finance_team\"\n }\n }\n ]\n }\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n}" } ]
{ "domain": "Financial Transactions", "data_type": "structured", "query_type": "listing_with_filters", "pattern": "initial", "pattern_type": "sorted_listing", "size": 10, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: Financial Transactions\n\nField Mappings:\n{\n \"properties\": {\n \"ticketId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"description\": {\n \"type\": \"text\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"priority\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"assignee\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"price\": {\n \"type\": \"double\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"ticketId\": \"TXN-1001\",\n \"title\": \"Failed wire transfer\",\n \"description\": \"Customer reported a failed wire transfer of $5,000 to external account.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"network\",\n \"assignee\": \"tech_support\",\n \"createdAt\": \"2025-10-20T08:15:30Z\",\n \"price\": 5000,\n \"documentContentWordsChunked\": [\n {\n \"passage\": \"Wire transfer failed due to network timeout.\",\n \"embedding\": [\n 0,\n 0,\n \"...\"\n ]\n }\n ]\n },\n {\n \"ticketId\": \"TXN-1002\",\n \"title\": \"Incorrect transaction fee\",\n \"description\": \"Client was charged an extra $15 fee on a domestic transfer.\",\n \"status\": \"resolved\",\n \"priority\": \"medium\",\n \"category\": \"billing\",\n \"assignee\": \"finance_team\",\n \"createdAt\": \"2025-03-15T14:42:10Z\",\n \"price\": 15,\n \"documentContentWordsChunked\": [\n {\n \"passage\": \"Fee discrepancy identified in transaction logs.\",\n \"embedding\": [\n 0,\n 0,\n \"...\"\n ]\n }\n ]\n },\n {\n \"ticketId\": \"TXN-1003\",\n \"title\": \"Delayed ACH deposit\",\n \"description\": \"ACH deposit pending for 3 business days, client awaiting funds.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"network\",\n \"assignee\": \"tech_support\",\n \"createdAt\": \"2025-10-22T11:05:45Z\",\n \"price\": 0,\n \"documentContentWordsChunked\": [\n {\n \"passage\": \"ACH processing delay due to network congestion.\",\n \"embedding\": [\n 0,\n 0,\n \"...\"\n ]\n }\n ]\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Show open tickets\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Here are the open tickets in the system.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"Show open tickets\",\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": [\n {\n \"term\": {\n \"status\": \"open\"\n }\n }\n ]\n }\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n }\n]\n\nUser Query: List high-priority network tickets assigned to tech support\n\nRephrased Query: Retrieve open tickets with high priority in the network category assigned to tech support\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 10,\n \"from\": 10,\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": [\n {\n \"term\": {\n \"status\": \"open\"\n }\n },\n {\n \"term\": {\n \"priority\": \"high\"\n }\n },\n {\n \"term\": {\n \"category\": \"network\"\n }\n },\n {\n \"term\": {\n \"assignee\": \"tech_support\"\n }\n }\n ]\n }\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n}" } ]
{ "domain": "Financial Transactions", "data_type": "structured", "query_type": "listing_with_filters", "pattern": "pagination", "pattern_type": "next_page", "size": 10, "from": 10, "is_pagination": true }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: Social Media Posts\n\nField Mappings:\n{\n \"properties\": {\n \"documentId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"author\": {\n \"type\": \"keyword\"\n },\n \"department\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"fileType\": {\n \"type\": \"keyword\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"tags\": {\n \"type\": \"keyword\"\n },\n \"confidentialityLevel\": {\n \"type\": \"keyword\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"documentId\": \"doc-001\",\n \"title\": \"IT Security Policy Overview\",\n \"author\": \"alice.smith\",\n \"department\": \"IT Security\",\n \"createdAt\": \"2024-02-15T09:30:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"policy\",\n \"tags\": [\n \"security\",\n \"policy\",\n \"overview\"\n ],\n \"confidentialityLevel\": \"internal\"\n },\n {\n \"documentId\": \"doc-002\",\n \"title\": \"Finance Quarterly Report Q1 2024\",\n \"author\": \"bob.jones\",\n \"department\": \"Finance\",\n \"createdAt\": \"2024-04-10T14:20:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"draft\",\n \"category\": \"report\",\n \"tags\": [\n \"finance\",\n \"quarterly\",\n \"Q1\"\n ],\n \"confidentialityLevel\": \"confidential\"\n },\n {\n \"documentId\": \"doc-003\",\n \"title\": \"Remote Work Guidelines\",\n \"author\": \"carol.lee\",\n \"department\": \"Human Resources\",\n \"createdAt\": \"2023-12-01T08:00:00Z\",\n \"fileType\": \"docx\",\n \"status\": \"approved\",\n \"category\": \"guideline\",\n \"tags\": [\n \"remote\",\n \"work\",\n \"policy\"\n ],\n \"confidentialityLevel\": \"public\"\n },\n {\n \"documentId\": \"doc-004\",\n \"title\": \"Marketing Campaign Plan 2025\",\n \"author\": \"dave.kumar\",\n \"department\": \"Marketing\",\n \"createdAt\": \"2024-09-05T11:45:00Z\",\n \"fileType\": \"pptx\",\n \"status\": \"approved\",\n \"category\": \"plan\",\n \"tags\": [\n \"marketing\",\n \"campaign\",\n \"2025\"\n ],\n \"confidentialityLevel\": \"internal\"\n },\n {\n \"documentId\": \"doc-005\",\n \"title\": \"IT Security Incident Response Procedure\",\n \"author\": \"eve.wang\",\n \"department\": \"IT Security\",\n \"createdAt\": \"2024-06-20T10:15:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"procedure\",\n \"tags\": [\n \"incident\",\n \"response\",\n \"security\"\n ],\n \"confidentialityLevel\": \"confidential\"\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Show approved policies from IT Security\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, I will retrieve the approved policy documents belonging to the IT Security department.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"List PDFs from Finance department after 2024\",\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"term\": {\n \"fileType\": \"pdf\"\n }\n },\n {\n \"term\": {\n \"department\": \"Finance\"\n }\n },\n {\n \"range\": {\n \"createdAt\": {\n \"gt\": \"2024-01-01T00:00:00Z\"\n }\n }\n }\n ]\n }\n }\n }\n }\n]\n\nUser Query: Show approved policies from IT Security\n\nRephrased Query: List approved policy documents in the IT Security department\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"hybrid_search_with_filters\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 10,\n \"from\": 10,\n \"query\": {\n \"hybrid\": {\n \"text\": \"approved policy documents IT Security\",\n \"filter\": {\n \"bool\": {\n \"must\": [\n {\n \"term\": {\n \"status\": \"approved\"\n }\n },\n {\n \"term\": {\n \"department\": \"IT Security\"\n }\n },\n {\n \"term\": {\n \"category\": \"policy\"\n }\n }\n ]\n }\n }\n }\n }\n }\n}" } ]
{ "domain": "Social Media Posts", "data_type": "unstructured", "query_type": "hybrid_search_with_filters", "pattern": "pagination", "pattern_type": "next_page", "size": 10, "from": 10, "is_pagination": true }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: Medical Records\n\nField Mappings:\n{\n \"properties\": {\n \"documentId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"author\": {\n \"type\": \"keyword\"\n },\n \"department\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"fileType\": {\n \"type\": \"keyword\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"tags\": {\n \"type\": \"keyword\"\n },\n \"confidentialityLevel\": {\n \"type\": \"keyword\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"documentId\": \"MR-001\",\n \"title\": \"IT Security Policy Overview\",\n \"author\": \"alice.smith\",\n \"department\": \"IT Security\",\n \"createdAt\": \"2024-02-15\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"policy\",\n \"tags\": [\n \"security\",\n \"policy\"\n ],\n \"confidentialityLevel\": \"high\"\n },\n {\n \"documentId\": \"MR-002\",\n \"title\": \"Patient Data Handling Guidelines\",\n \"author\": \"bob.johnson\",\n \"department\": \"Compliance\",\n \"createdAt\": \"2023-11-03\",\n \"fileType\": \"docx\",\n \"status\": \"draft\",\n \"category\": \"guideline\",\n \"tags\": [\n \"patient\",\n \"data\",\n \"privacy\"\n ],\n \"confidentialityLevel\": \"medium\"\n },\n {\n \"documentId\": \"MR-003\",\n \"title\": \"Remote Work Security Checklist\",\n \"author\": \"carol.lee\",\n \"department\": \"IT Security\",\n \"createdAt\": \"2024-05-20\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"checklist\",\n \"tags\": [\n \"remote\",\n \"security\",\n \"checklist\"\n ],\n \"confidentialityLevel\": \"low\"\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Show 10 recent approved policies from IT Security.\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Here is a DSL query that returns the 10 most recent approved IT Security policies.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"Show 10 recent approved policies from IT Security.\",\n \"dsl_type\": \"hybrid_search_with_filters\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"query\": {\n \"hybrid\": {\n \"query\": \"policy\",\n \"embedder\": \"text_embedding\",\n \"filter\": {\n \"bool\": {\n \"must\": [\n {\n \"term\": {\n \"status\": \"approved\"\n }\n },\n {\n \"term\": {\n \"department\": \"IT Security\"\n }\n }\n ]\n }\n }\n }\n }\n }\n }\n]\n\nUser Query: Show 17 approved policies from IT Security department after 2024.\n\nRephrased Query: Retrieve 17 documents where status is approved, department is IT Security, and createdAt is after 2024-01-01.\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"hybrid_search_with_filters\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 17,\n \"from\": 0,\n \"query\": {\n \"hybrid\": {\n \"query\": \"policy\",\n \"embedder\": \"text_embedding\",\n \"filter\": {\n \"bool\": {\n \"must\": [\n {\n \"term\": {\n \"status\": \"approved\"\n }\n },\n {\n \"term\": {\n \"department\": \"IT Security\"\n }\n },\n {\n \"range\": {\n \"createdAt\": {\n \"gte\": \"2024-01-01\"\n }\n }\n }\n ]\n }\n }\n }\n }\n }\n}" } ]
{ "domain": "Medical Records", "data_type": "unstructured", "query_type": "hybrid_search_with_filters", "pattern": "initial", "pattern_type": "complex_query", "size": 17, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: Corporate Blog Posts\n\nField Mappings:\n{\n \"properties\": {\n \"documentId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"author\": {\n \"type\": \"keyword\"\n },\n \"department\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"fileType\": {\n \"type\": \"keyword\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"tags\": {\n \"type\": \"keyword\"\n },\n \"confidentialityLevel\": {\n \"type\": \"keyword\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"documentId\": \"doc-001\",\n \"title\": \"IT Security Policy Overview\",\n \"author\": \"alice.smith\",\n \"department\": \"IT Security\",\n \"createdAt\": \"2024-02-15T09:30:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"policy\",\n \"tags\": [\n \"security\",\n \"policy\",\n \"overview\"\n ],\n \"confidentialityLevel\": \"internal\"\n },\n {\n \"documentId\": \"doc-002\",\n \"title\": \"Remote Work Guidelines\",\n \"author\": \"bob.johnson\",\n \"department\": \"Human Resources\",\n \"createdAt\": \"2024-05-01T14:12:00Z\",\n \"fileType\": \"docx\",\n \"status\": \"draft\",\n \"category\": \"guideline\",\n \"tags\": [\n \"remote\",\n \"work\",\n \"policy\"\n ],\n \"confidentialityLevel\": \"public\"\n },\n {\n \"documentId\": \"doc-003\",\n \"title\": \"Finance Department Expense Policy\",\n \"author\": \"carol.lee\",\n \"department\": \"Finance\",\n \"createdAt\": \"2023-11-20T08:45:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"policy\",\n \"tags\": [\n \"expense\",\n \"finance\",\n \"policy\"\n ],\n \"confidentialityLevel\": \"confidential\"\n },\n {\n \"documentId\": \"doc-004\",\n \"title\": \"Data Privacy Regulations Summary\",\n \"author\": \"david.kim\",\n \"department\": \"Legal\",\n \"createdAt\": \"2024-01-10T11:00:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"regulation\",\n \"tags\": [\n \"privacy\",\n \"data\",\n \"regulation\"\n ],\n \"confidentialityLevel\": \"internal\"\n },\n {\n \"documentId\": \"doc-005\",\n \"title\": \"IT Security Incident Response Procedure\",\n \"author\": \"eve.martinez\",\n \"department\": \"IT Security\",\n \"createdAt\": \"2024-03-22T16:20:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"procedure\",\n \"tags\": [\n \"incident\",\n \"response\",\n \"security\"\n ],\n \"confidentialityLevel\": \"confidential\"\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Can you give me the latest security policies?\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, here are the most recent security policies from the IT Security department.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"Show 10 recent documents\",\n \"dsl_type\": \"simple_search\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"match_all\": {}\n },\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n }\n }\n }\n]\n\nUser Query: Show 46 approved policies from IT Security\n\nRephrased Query: Retrieve 46 documents where status is approved, category is policy, and department is IT Security\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"hybrid_search_with_filters\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 46,\n \"from\": 0,\n \"query\": {\n \"hybrid\": {\n \"query\": {\n \"text_expansion\": {\n \"model_id\": \"text-embedding-ada-002\",\n \"model_text\": \"policy\"\n }\n },\n \"filter\": {\n \"bool\": {\n \"must\": [\n {\n \"term\": {\n \"status\": \"approved\"\n }\n },\n {\n \"term\": {\n \"category\": \"policy\"\n }\n },\n {\n \"term\": {\n \"department\": \"IT Security\"\n }\n }\n ]\n }\n }\n }\n }\n }\n}" } ]
{ "domain": "Corporate Blog Posts", "data_type": "unstructured", "query_type": "hybrid_search_with_filters", "pattern": "initial", "pattern_type": "complex_query", "size": 46, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: Supplier Contracts\n\nField Mappings:\n{\n \"properties\": {\n \"ticketId\": {\n \"type\": \"keyword\"\n },\n \"productId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"description\": {\n \"type\": \"text\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"priority\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"assignee\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"price\": {\n \"type\": \"float\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"ticketId\": \"SC-1001\",\n \"productId\": \"PR-2001\",\n \"title\": \"Network Infrastructure Upgrade Contract\",\n \"description\": \"Contract for upgrading the supplier's network infrastructure across all regional data centers.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"network\",\n \"assignee\": \"tech_support\",\n \"createdAt\": \"2024-09-15T08:30:00Z\",\n \"price\": 125000\n },\n {\n \"ticketId\": \"SC-1002\",\n \"productId\": \"PR-2002\",\n \"title\": \"Software License Renewal\",\n \"description\": \"Renewal of enterprise software licenses for the upcoming fiscal year.\",\n \"status\": \"closed\",\n \"priority\": \"medium\",\n \"category\": \"software\",\n \"assignee\": \"legal_team\",\n \"createdAt\": \"2024-07-02T14:12:00Z\",\n \"price\": 45000\n },\n {\n \"ticketId\": \"SC-1003\",\n \"productId\": \"PR-2003\",\n \"title\": \"Supply Chain Risk Assessment\",\n \"description\": \"Assessment of risks associated with third‑party suppliers in the logistics chain.\",\n \"status\": \"in_progress\",\n \"priority\": \"high\",\n \"category\": \"risk\",\n \"assignee\": \"risk_management\",\n \"createdAt\": \"2024-08-20T10:45:00Z\",\n \"price\": 30000\n },\n {\n \"ticketId\": \"SC-1004\",\n \"productId\": \"PR-2004\",\n \"title\": \"Hardware Procurement for New Offices\",\n \"description\": \"Procurement of servers, workstations, and networking gear for newly opened offices.\",\n \"status\": \"open\",\n \"priority\": \"low\",\n \"category\": \"hardware\",\n \"assignee\": \"procurement\",\n \"createdAt\": \"2024-09-01T09:00:00Z\",\n \"price\": 80000\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Show open high‑priority network tickets assigned to tech support\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, retrieving the requested tickets...\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"List closed software tickets from July\",\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": [\n {\n \"term\": {\n \"status\": \"closed\"\n }\n },\n {\n \"term\": {\n \"category\": \"software\"\n }\n },\n {\n \"range\": {\n \"createdAt\": {\n \"gte\": \"2024-07-01T00:00:00Z\",\n \"lt\": \"2024-08-01T00:00:00Z\"\n }\n }\n }\n ]\n }\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n }\n]\n\nUser Query: Show open high‑priority network tickets assigned to tech support\n\nRephrased Query: List open tickets with priority high, category network, assigned to tech_support\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": [\n {\n \"term\": {\n \"status\": \"open\"\n }\n },\n {\n \"term\": {\n \"priority\": \"high\"\n }\n },\n {\n \"term\": {\n \"category\": \"network\"\n }\n },\n {\n \"term\": {\n \"assignee\": \"tech_support\"\n }\n }\n ]\n }\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n}" } ]
{ "domain": "Supplier Contracts", "data_type": "structured", "query_type": "listing_with_filters", "pattern": "initial", "pattern_type": "filtered_search", "size": 10, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: Financial Transactions\n\nField Mappings:\n{\n \"properties\": {\n \"ticketId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"description\": {\n \"type\": \"text\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"priority\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"assignee\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"price\": {\n \"type\": \"double\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"ticketId\": \"TCK-1001\",\n \"title\": \"Invoice discrepancy for client A\",\n \"description\": \"The invoice amount does not match the transaction record.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"billing\",\n \"assignee\": \"finance_team\",\n \"createdAt\": \"2025-10-20T09:15:00Z\",\n \"price\": 1250\n },\n {\n \"ticketId\": \"TCK-1002\",\n \"title\": \"Unauthorized transaction alert\",\n \"description\": \"Potential fraud detected on account 987654.\",\n \"status\": \"in_progress\",\n \"priority\": \"critical\",\n \"category\": \"security\",\n \"assignee\": \"risk_management\",\n \"createdAt\": \"2025-10-18T14:30:00Z\",\n \"price\": 0\n },\n {\n \"ticketId\": \"TCK-1003\",\n \"title\": \"Monthly reconciliation pending\",\n \"description\": \"Reconcile March transactions for the corporate account.\",\n \"status\": \"closed\",\n \"priority\": \"medium\",\n \"category\": \"accounting\",\n \"assignee\": \"finance_team\",\n \"createdAt\": \"2025-09-30T11:00:00Z\",\n \"price\": 0\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"List all tickets\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Here are the first 10 tickets...\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"List all tickets\",\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": []\n }\n },\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n }\n]\n\nUser Query: Show open high-priority tickets assigned to the finance team\n\nRephrased Query: List open tickets with high priority assigned to the finance team\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": [\n {\n \"term\": {\n \"status\": \"open\"\n }\n },\n {\n \"term\": {\n \"priority\": \"high\"\n }\n },\n {\n \"term\": {\n \"assignee\": \"finance_team\"\n }\n }\n ]\n }\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n}" } ]
{ "domain": "Financial Transactions", "data_type": "structured", "query_type": "listing_with_filters", "pattern": "initial", "pattern_type": "sorted_listing", "size": 10, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: Research Papers\n\nField Mappings:\n{\n \"properties\": {\n \"documentId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"author\": {\n \"type\": \"keyword\"\n },\n \"department\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"fileType\": {\n \"type\": \"keyword\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"tags\": {\n \"type\": \"keyword\"\n },\n \"confidentialityLevel\": {\n \"type\": \"keyword\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"documentId\": \"doc-001\",\n \"title\": \"IT Security Policy Overview\",\n \"author\": \"alice.smith\",\n \"department\": \"IT Security\",\n \"createdAt\": \"2023-11-15T09:30:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"policy\",\n \"tags\": [\n \"security\",\n \"policy\",\n \"overview\"\n ],\n \"confidentialityLevel\": \"internal\"\n },\n {\n \"documentId\": \"doc-002\",\n \"title\": \"Finance Department Quarterly Report 2024 Q1\",\n \"author\": \"bob.johnson\",\n \"department\": \"Finance\",\n \"createdAt\": \"2024-04-20T14:00:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"draft\",\n \"category\": \"report\",\n \"tags\": [\n \"finance\",\n \"quarterly\",\n \"2024\"\n ],\n \"confidentialityLevel\": \"confidential\"\n },\n {\n \"documentId\": \"doc-003\",\n \"title\": \"Remote Work Guidelines\",\n \"author\": \"carol.lee\",\n \"department\": \"Human Resources\",\n \"createdAt\": \"2024-01-10T08:15:00Z\",\n \"fileType\": \"docx\",\n \"status\": \"approved\",\n \"category\": \"guideline\",\n \"tags\": [\n \"remote\",\n \"work\",\n \"policy\"\n ],\n \"confidentialityLevel\": \"public\"\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"List PDFs from Finance department after 2024\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, fetching PDF documents from Finance created after 2024...\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"List PDFs from Finance department after 2024\",\n \"dsl_type\": \"hybrid_search_with_filters\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"knn\": {\n \"documentContentWordsChunked.embedding\": {\n \"vector\": [\n 0,\n 0,\n 0\n ],\n \"k\": 10\n }\n }\n }\n ],\n \"filter\": {\n \"bool\": {\n \"must\": [\n {\n \"term\": {\n \"department\": \"Finance\"\n }\n },\n {\n \"term\": {\n \"fileType\": \"pdf\"\n }\n },\n {\n \"range\": {\n \"createdAt\": {\n \"gt\": \"2024-01-01T00:00:00Z\"\n }\n }\n }\n ]\n }\n }\n }\n }\n }\n }\n]\n\nUser Query: Show approved policies from IT Security\n\nRephrased Query: Retrieve all approved policy documents belonging to the IT Security department\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"hybrid_search_with_filters\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"knn\": {\n \"documentContentWordsChunked.embedding\": {\n \"vector\": [\n 0,\n 0,\n 0\n ],\n \"k\": 10\n }\n }\n }\n ],\n \"filter\": {\n \"bool\": {\n \"must\": [\n {\n \"term\": {\n \"status\": \"approved\"\n }\n },\n {\n \"term\": {\n \"department\": \"IT Security\"\n }\n },\n {\n \"term\": {\n \"category\": \"policy\"\n }\n }\n ]\n }\n }\n }\n }\n }\n}" } ]
{ "domain": "Research Papers", "data_type": "unstructured", "query_type": "hybrid_search_with_filters", "pattern": "initial", "pattern_type": "sorted_listing", "size": 10, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: Product Reviews\n\nField Mappings:\n{\n \"properties\": {\n \"documentId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"author\": {\n \"type\": \"keyword\"\n },\n \"department\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"fileType\": {\n \"type\": \"keyword\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"tags\": {\n \"type\": \"keyword\"\n },\n \"confidentialityLevel\": {\n \"type\": \"keyword\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"documentId\": \"PR-001\",\n \"title\": \"Wireless Earbuds Review\",\n \"author\": \"alice.smith\",\n \"department\": \"Consumer Electronics\",\n \"createdAt\": \"2023-11-05T14:23:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"audio\",\n \"tags\": [\n \"earbuds\",\n \"bluetooth\",\n \"sound quality\"\n ],\n \"confidentialityLevel\": \"public\"\n },\n {\n \"documentId\": \"PR-002\",\n \"title\": \"Smartphone Battery Life Comparison\",\n \"author\": \"bob.jones\",\n \"department\": \"Mobile Devices\",\n \"createdAt\": \"2024-02-12T09:10:45Z\",\n \"fileType\": \"docx\",\n \"status\": \"draft\",\n \"category\": \"battery\",\n \"tags\": [\n \"battery\",\n \"performance\",\n \"charging\"\n ],\n \"confidentialityLevel\": \"internal\"\n },\n {\n \"documentId\": \"PR-003\",\n \"title\": \"Laptop Keyboard Feedback Survey\",\n \"author\": \"carla.lee\",\n \"department\": \"Computers\",\n \"createdAt\": \"2024-07-20T18:45:30Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"accessories\",\n \"tags\": [\n \"keyboard\",\n \"typing\",\n \"comfort\"\n ],\n \"confidentialityLevel\": \"public\"\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Can you give me a summary of the latest product reviews?\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure! I can provide a brief overview of the most recent reviews across categories such as audio, mobile devices, and computers.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"List all approved product reviews\",\n \"dsl_type\": \"match_all\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"bool\": {\n \"filter\": [\n {\n \"term\": {\n \"status\": \"approved\"\n }\n }\n ]\n }\n }\n }\n }\n]\n\nUser Query: Show tickets\n\nRephrased Query: Retrieve a list of tickets\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"hybrid_search\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"match_all\": {}\n }\n }\n}" } ]
{ "domain": "Product Reviews", "data_type": "unstructured", "query_type": "hybrid_search", "pattern": "initial", "pattern_type": "filtered_search", "size": 10, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: IT Policies\n\nField Mappings:\n{\n \"properties\": {\n \"documentId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"author\": {\n \"type\": \"keyword\"\n },\n \"department\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"fileType\": {\n \"type\": \"keyword\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"tags\": {\n \"type\": \"keyword\"\n },\n \"confidentialityLevel\": {\n \"type\": \"keyword\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"documentId\": \"doc-001\",\n \"title\": \"Remote Work Security Policy\",\n \"author\": \"alice.smith\",\n \"department\": \"IT Security\",\n \"createdAt\": \"2024-02-15T09:30:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"security\",\n \"tags\": [\n \"remote\",\n \"vpn\",\n \"authentication\"\n ],\n \"confidentialityLevel\": \"internal\"\n },\n {\n \"documentId\": \"doc-002\",\n \"title\": \"Data Retention Guidelines\",\n \"author\": \"bob.jones\",\n \"department\": \"Legal\",\n \"createdAt\": \"2023-11-01T14:00:00Z\",\n \"fileType\": \"docx\",\n \"status\": \"draft\",\n \"category\": \"compliance\",\n \"tags\": [\n \"retention\",\n \"archiving\"\n ],\n \"confidentialityLevel\": \"confidential\"\n },\n {\n \"documentId\": \"doc-003\",\n \"title\": \"Approved IT Asset Management Policy\",\n \"author\": \"carol.lee\",\n \"department\": \"IT Security\",\n \"createdAt\": \"2024-05-20T11:45:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"asset\",\n \"tags\": [\n \"hardware\",\n \"software\",\n \"inventory\"\n ],\n \"confidentialityLevel\": \"internal\"\n },\n {\n \"documentId\": \"doc-004\",\n \"title\": \"Password Complexity Requirements\",\n \"author\": \"dave.kumar\",\n \"department\": \"IT Security\",\n \"createdAt\": \"2024-01-10T08:20:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"security\",\n \"tags\": [\n \"password\",\n \"complexity\",\n \"policy\"\n ],\n \"confidentialityLevel\": \"public\"\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Can you list the approved policies from IT Security?\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, I will retrieve the approved IT Security policies for you.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"Show all documents\",\n \"dsl_type\": \"simple_match_all\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"match_all\": {}\n },\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n }\n }\n }\n]\n\nUser Query: Show approved policies from IT Security\n\nRephrased Query: Retrieve documents where status is approved and department is IT Security\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"hybrid_search_with_filters\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"hybrid\": {\n \"query\": {\n \"multi_match\": {\n \"query\": \"policy\",\n \"fields\": [\n \"title\",\n \"tags\"\n ]\n }\n },\n \"filter\": {\n \"bool\": {\n \"must\": [\n {\n \"term\": {\n \"status\": \"approved\"\n }\n },\n {\n \"term\": {\n \"department\": \"IT Security\"\n }\n }\n ]\n }\n }\n }\n }\n }\n}" } ]
{ "domain": "IT Policies", "data_type": "unstructured", "query_type": "hybrid_search_with_filters", "pattern": "initial", "pattern_type": "sorted_listing", "size": 10, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: Legal Policies\n\nField Mappings:\n{\n \"properties\": {\n \"documentId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"author\": {\n \"type\": \"keyword\"\n },\n \"department\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"fileType\": {\n \"type\": \"keyword\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"tags\": {\n \"type\": \"keyword\"\n },\n \"confidentialityLevel\": {\n \"type\": \"keyword\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"documentId\": \"doc-001\",\n \"title\": \"IT Security Approved Policy\",\n \"author\": \"alice.smith\",\n \"department\": \"IT Security\",\n \"createdAt\": \"2024-02-15T09:30:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"policy\",\n \"tags\": [\n \"security\",\n \"access\"\n ],\n \"confidentialityLevel\": \"internal\"\n },\n {\n \"documentId\": \"doc-002\",\n \"title\": \"Finance Quarterly Report 2024\",\n \"author\": \"bob.jones\",\n \"department\": \"Finance\",\n \"createdAt\": \"2024-04-10T14:00:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"draft\",\n \"category\": \"report\",\n \"tags\": [\n \"quarterly\",\n \"2024\"\n ],\n \"confidentialityLevel\": \"confidential\"\n },\n {\n \"documentId\": \"doc-003\",\n \"title\": \"Remote Work Guidelines\",\n \"author\": \"carol.lee\",\n \"department\": \"HR\",\n \"createdAt\": \"2023-11-01T08:45:00Z\",\n \"fileType\": \"docx\",\n \"status\": \"approved\",\n \"category\": \"guideline\",\n \"tags\": [\n \"remote\",\n \"policy\"\n ],\n \"confidentialityLevel\": \"public\"\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"List PDFs from Finance department after 2024\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, fetching PDF documents from Finance created after 2024...\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"List PDFs from Finance department after 2024\",\n \"dsl_type\": \"hybrid_search_with_filters\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"query\": {\n \"hybrid\": {\n \"query\": {\n \"text_expansion\": {\n \"model_id\": \"text-embedding-768\",\n \"fields\": [\n \"title\",\n \"tags\"\n ],\n \"query\": \"Finance\"\n }\n },\n \"filter\": {\n \"bool\": {\n \"must\": [\n {\n \"term\": {\n \"department\": \"Finance\"\n }\n },\n {\n \"term\": {\n \"fileType\": \"pdf\"\n }\n },\n {\n \"range\": {\n \"createdAt\": {\n \"gt\": \"2024-01-01T00:00:00Z\"\n }\n }\n }\n ]\n }\n }\n }\n }\n }\n }\n]\n\nUser Query: Show approved policies from IT Security\n\nRephrased Query: Retrieve approved policy documents where department is IT Security\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"hybrid_search_with_filters\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"hybrid\": {\n \"query\": {\n \"text_expansion\": {\n \"model_id\": \"text-embedding-768\",\n \"fields\": [\n \"title\",\n \"tags\",\n \"category\"\n ],\n \"query\": \"policy\"\n }\n },\n \"filter\": {\n \"bool\": {\n \"must\": [\n {\n \"term\": {\n \"status\": \"approved\"\n }\n },\n {\n \"term\": {\n \"department\": \"IT Security\"\n }\n },\n {\n \"term\": {\n \"category\": \"policy\"\n }\n }\n ]\n }\n }\n }\n }\n }\n}" } ]
{ "domain": "Legal Policies", "data_type": "unstructured", "query_type": "hybrid_search_with_filters", "pattern": "initial", "pattern_type": "keyword_search", "size": 10, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: Ticket Management\n\nField Mappings:\n{\n \"properties\": {\n \"ticketId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"description\": {\n \"type\": \"text\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"priority\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"assignee\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"price\": {\n \"type\": \"float\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"ticketId\": \"TCK-001\",\n \"title\": \"Network outage in building A\",\n \"description\": \"Users cannot access the internet on the 3rd floor.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"network\",\n \"assignee\": \"tech_support\",\n \"createdAt\": \"2025-10-20T08:15:00Z\",\n \"price\": 0\n },\n {\n \"ticketId\": \"TCK-002\",\n \"title\": \"Software license renewal\",\n \"description\": \"Renewal needed for accounting software.\",\n \"status\": \"resolved\",\n \"priority\": \"medium\",\n \"category\": \"software\",\n \"assignee\": \"procurement\",\n \"createdAt\": \"2025-09-15T14:30:00Z\",\n \"price\": 1200\n },\n {\n \"ticketId\": \"TCK-003\",\n \"title\": \"Printer jam in office 210\",\n \"description\": \"Paper jam causing delays in printing reports.\",\n \"status\": \"closed\",\n \"priority\": \"low\",\n \"category\": \"hardware\",\n \"assignee\": \"it_support\",\n \"createdAt\": \"2025-08-05T09:45:00Z\",\n \"price\": 0\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"List high‑priority network tickets assigned to tech support\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, here are the high‑priority network tickets assigned to tech support...\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"Show tickets\",\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": []\n }\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n }\n]\n\nUser Query: Show open tickets\n\nRephrased Query: List tickets where status is open\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 10,\n \"from\": 10,\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": [\n {\n \"term\": {\n \"status\": \"open\"\n }\n }\n ]\n }\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n}" } ]
{ "domain": "Ticket Management", "data_type": "structured", "query_type": "listing_with_filters", "pattern": "pagination", "pattern_type": "previous_page", "size": 10, "from": 10, "is_pagination": true }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: Technical Manuals - IT Security Policies\n\nField Mappings:\n{\n \"properties\": {\n \"documentId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"author\": {\n \"type\": \"keyword\"\n },\n \"department\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"fileType\": {\n \"type\": \"keyword\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"tags\": {\n \"type\": \"keyword\"\n },\n \"confidentialityLevel\": {\n \"type\": \"keyword\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"documentId\": \"doc-001\",\n \"title\": \"IT Security Policy – Access Control\",\n \"author\": \"alice.smith\",\n \"department\": \"IT Security\",\n \"createdAt\": \"2024-02-15T09:30:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"policy\",\n \"tags\": [\n \"access\",\n \"authentication\",\n \"authorization\"\n ],\n \"confidentialityLevel\": \"internal\"\n },\n {\n \"documentId\": \"doc-002\",\n \"title\": \"Remote Work Security Guidelines\",\n \"author\": \"bob.johnson\",\n \"department\": \"IT Security\",\n \"createdAt\": \"2024-05-10T14:12:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"guideline\",\n \"tags\": [\n \"remote\",\n \"vpn\",\n \"endpoint\"\n ],\n \"confidentialityLevel\": \"internal\"\n },\n {\n \"documentId\": \"doc-003\",\n \"title\": \"Data Encryption Standards\",\n \"author\": \"carol.lee\",\n \"department\": \"IT Security\",\n \"createdAt\": \"2023-11-20T08:45:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"draft\",\n \"category\": \"standard\",\n \"tags\": [\n \"encryption\",\n \"tls\",\n \"aes\"\n ],\n \"confidentialityLevel\": \"confidential\"\n },\n {\n \"documentId\": \"doc-004\",\n \"title\": \"Incident Response Procedure\",\n \"author\": \"dave.kumar\",\n \"department\": \"IT Security\",\n \"createdAt\": \"2024-01-05T11:00:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"procedure\",\n \"tags\": [\n \"incident\",\n \"response\",\n \"forensics\"\n ],\n \"confidentialityLevel\": \"internal\"\n },\n {\n \"documentId\": \"doc-005\",\n \"title\": \"Password Management Policy\",\n \"author\": \"eve.wang\",\n \"department\": \"IT Security\",\n \"createdAt\": \"2024-03-22T16:20:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"policy\",\n \"tags\": [\n \"password\",\n \"complexity\",\n \"rotation\"\n ],\n \"confidentialityLevel\": \"internal\"\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Show me the latest security policies.\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, here are the most recent approved policies from the IT Security department.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"List 10 recent IT Security documents\",\n \"dsl_type\": \"hybrid_search\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"hybrid\": {\n \"query\": {\n \"text_expansion\": {\n \"model_id\": \"text-embedding-768\",\n \"model_text\": \"IT Security\"\n }\n }\n }\n }\n }\n }\n]\n\nUser Query: Show 38 approved policies from IT Security\n\nRephrased Query: Retrieve 38 documents where status is 'approved', department is 'IT Security', and fileType is 'pdf'\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"hybrid_search_with_filters\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 38,\n \"from\": 0,\n \"query\": {\n \"hybrid\": {\n \"query\": {\n \"text_expansion\": {\n \"model_id\": \"text-embedding-768\",\n \"model_text\": \"security policy\"\n }\n },\n \"filter\": {\n \"bool\": {\n \"must\": [\n {\n \"term\": {\n \"status\": \"approved\"\n }\n },\n {\n \"term\": {\n \"department\": \"IT Security\"\n }\n },\n {\n \"term\": {\n \"fileType\": \"pdf\"\n }\n }\n ]\n }\n }\n }\n }\n }\n}" } ]
{ "domain": "Technical Manuals - IT Security Policies", "data_type": "unstructured", "query_type": "hybrid_search_with_filters", "pattern": "initial", "pattern_type": "filtered_search", "size": 38, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: Financial Transactions\n\nField Mappings:\n{\n \"properties\": {\n \"ticketId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"description\": {\n \"type\": \"text\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"priority\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"assignee\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"price\": {\n \"type\": \"float\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"ticketId\": \"TXN-1001\",\n \"title\": \"Payment processing error\",\n \"description\": \"Transaction failed due to insufficient funds.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"network\",\n \"assignee\": \"tech_support\",\n \"createdAt\": \"2024-11-01T08:15:30Z\",\n \"price\": 1250.75,\n \"documentContentWordsChunked\": [\n {\n \"passage\": \"The payment gateway returned a 402 error.\",\n \"embedding\": [\n 0,\n 0,\n 0\n ]\n }\n ]\n },\n {\n \"ticketId\": \"TXN-1002\",\n \"title\": \"Invoice discrepancy\",\n \"description\": \"Customer reported a mismatch between invoice total and payment amount.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"network\",\n \"assignee\": \"tech_support\",\n \"createdAt\": \"2024-11-02T11:42:10Z\",\n \"price\": 980,\n \"documentContentWordsChunked\": [\n {\n \"passage\": \"Review the billing module for rounding errors.\",\n \"embedding\": [\n 0,\n 0,\n 0\n ]\n }\n ]\n },\n {\n \"ticketId\": \"TXN-1003\",\n \"title\": \"Delayed settlement\",\n \"description\": \"Settlement of batch #45 is delayed beyond SLA.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"network\",\n \"assignee\": \"tech_support\",\n \"createdAt\": \"2024-11-03T14:07:55Z\",\n \"price\": 4320.1,\n \"documentContentWordsChunked\": [\n {\n \"passage\": \"Investigate the settlement queue for bottlenecks.\",\n \"embedding\": [\n 0,\n 0,\n 0\n ]\n }\n ]\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Show 48 open high-priority network tickets assigned to tech support\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, I will retrieve 48 tickets that match those criteria.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"Show 10 tickets\",\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": []\n }\n }\n }\n }\n]\n\nUser Query: Show 48 open high-priority network tickets assigned to tech support\n\nRephrased Query: List 48 tickets where status is open, priority is high, category is network, and assignee is tech_support\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 48,\n \"from\": 0,\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": [\n {\n \"term\": {\n \"status\": \"open\"\n }\n },\n {\n \"term\": {\n \"priority\": \"high\"\n }\n },\n {\n \"term\": {\n \"category\": \"network\"\n }\n },\n {\n \"term\": {\n \"assignee\": \"tech_support\"\n }\n }\n ]\n }\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n}" } ]
{ "domain": "Financial Transactions", "data_type": "structured", "query_type": "listing_with_filters", "pattern": "initial", "pattern_type": "sorted_listing", "size": 48, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: Supplier Contracts\n\nField Mappings:\n{\n \"properties\": {\n \"ticketId\": {\n \"type\": \"keyword\"\n },\n \"productId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"description\": {\n \"type\": \"text\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"priority\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"assignee\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"price\": {\n \"type\": \"float\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"ticketId\": \"TCK-1001\",\n \"productId\": \"PRD-2001\",\n \"title\": \"Network latency issue in data center\",\n \"description\": \"Customer reports intermittent latency spikes affecting API calls.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"network\",\n \"assignee\": \"tech_support\",\n \"createdAt\": \"2024-10-12T08:15:30Z\",\n \"price\": 12500\n },\n {\n \"ticketId\": \"TCK-1002\",\n \"productId\": \"PRD-2002\",\n \"title\": \"Contract renewal for supplier X\",\n \"description\": \"Review and approve renewal terms for supplier X's annual contract.\",\n \"status\": \"resolved\",\n \"priority\": \"medium\",\n \"category\": \"contract\",\n \"assignee\": \"legal_team\",\n \"createdAt\": \"2024-09-05T14:42:10Z\",\n \"price\": 85000\n },\n {\n \"ticketId\": \"TCK-1003\",\n \"productId\": \"PRD-2003\",\n \"title\": \"Price discrepancy on invoice #4532\",\n \"description\": \"Invoice shows higher price than agreed in the contract.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"finance\",\n \"assignee\": \"accounting\",\n \"createdAt\": \"2024-10-01T11:07:45Z\",\n \"price\": 2300.5\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Show open tickets\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Here are the open tickets in the system...\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"Show open tickets\",\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": [\n {\n \"term\": {\n \"status\": \"open\"\n }\n }\n ]\n }\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n }\n]\n\nUser Query: Show high-priority network tickets assigned to tech support\n\nRephrased Query: List open tickets with status open, priority high, category network, and assignee tech_support\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": [\n {\n \"term\": {\n \"status\": \"open\"\n }\n },\n {\n \"term\": {\n \"priority\": \"high\"\n }\n },\n {\n \"term\": {\n \"category\": \"network\"\n }\n },\n {\n \"term\": {\n \"assignee\": \"tech_support\"\n }\n }\n ]\n }\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n}" } ]
{ "domain": "Supplier Contracts", "data_type": "structured", "query_type": "listing_with_filters", "pattern": "refinement", "pattern_type": "narrow_scope", "size": 10, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: Customer Support Tickets\n\nField Mappings:\n{\n \"properties\": {\n \"ticketId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"description\": {\n \"type\": \"text\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"priority\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"assignee\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"price\": {\n \"type\": \"float\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"ticketId\": \"TCKT-001\",\n \"title\": \"Unable to access account\",\n \"description\": \"Customer reports inability to log into their account after password reset.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"authentication\",\n \"assignee\": \"tech_support\",\n \"createdAt\": \"2025-10-20T08:15:30Z\",\n \"price\": 0,\n \"documentContentWordsChunked\": [\n {\n \"passage\": \"Customer cannot log in after resetting password.\",\n \"embedding\": []\n }\n ]\n },\n {\n \"ticketId\": \"TCKT-002\",\n \"title\": \"Billing discrepancy on invoice\",\n \"description\": \"The invoice shows an extra charge that the customer did not authorize.\",\n \"status\": \"in_progress\",\n \"priority\": \"medium\",\n \"category\": \"billing\",\n \"assignee\": \"finance_team\",\n \"createdAt\": \"2025-10-18T14:42:10Z\",\n \"price\": 150.75,\n \"documentContentWordsChunked\": [\n {\n \"passage\": \"Extra charge appears on the latest invoice.\",\n \"embedding\": []\n }\n ]\n },\n {\n \"ticketId\": \"TCKT-003\",\n \"title\": \"Feature request: Dark mode\",\n \"description\": \"User requests a dark mode option for the web portal.\",\n \"status\": \"closed\",\n \"priority\": \"low\",\n \"category\": \"feature_request\",\n \"assignee\": \"product_manager\",\n \"createdAt\": \"2025-09-30T09:05:00Z\",\n \"price\": 0,\n \"documentContentWordsChunked\": [\n {\n \"passage\": \"User wants dark mode for better night-time usability.\",\n \"embedding\": []\n }\n ]\n }\n]\n\nChat History:\n[]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"show tickets\",\n \"dsl_type\": \"listing\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"match_all\": {}\n }\n }\n }\n]\n\nUser Query: Show tickets\n\nRephrased Query: List tickets without any specific filters\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"listing\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"match_all\": {}\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n}" } ]
{ "domain": "Customer Support Tickets", "data_type": "structured", "query_type": "listing", "pattern": "initial", "pattern_type": "sorted_listing", "size": 10, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: Legal Documents\n\nField Mappings:\n{\n \"properties\": {\n \"documentId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"author\": {\n \"type\": \"keyword\"\n },\n \"department\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"fileType\": {\n \"type\": \"keyword\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"tags\": {\n \"type\": \"keyword\"\n },\n \"confidentialityLevel\": {\n \"type\": \"keyword\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"documentId\": \"DOC-001\",\n \"title\": \"IT Security Policy – Access Control\",\n \"author\": \"alice.smith\",\n \"department\": \"IT Security\",\n \"createdAt\": \"2024-02-15T09:30:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"policy\",\n \"tags\": [\n \"access\",\n \"control\",\n \"authentication\"\n ],\n \"confidentialityLevel\": \"internal\"\n },\n {\n \"documentId\": \"DOC-002\",\n \"title\": \"Remote Work Guidelines\",\n \"author\": \"bob.johnson\",\n \"department\": \"Human Resources\",\n \"createdAt\": \"2023-11-01T14:00:00Z\",\n \"fileType\": \"docx\",\n \"status\": \"draft\",\n \"category\": \"guideline\",\n \"tags\": [\n \"remote\",\n \"work\",\n \"policy\"\n ],\n \"confidentialityLevel\": \"public\"\n },\n {\n \"documentId\": \"DOC-003\",\n \"title\": \"Finance Department Expense Policy\",\n \"author\": \"carol.lee\",\n \"department\": \"Finance\",\n \"createdAt\": \"2024-05-20T11:15:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"policy\",\n \"tags\": [\n \"expense\",\n \"reimbursement\"\n ],\n \"confidentialityLevel\": \"confidential\"\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Can you list the latest approved policies?\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, here are the most recent approved policies across all departments.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"Show 10 recent approved policies\",\n \"dsl_type\": \"hybrid_search\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"hybrid\": {\n \"query\": \"approved policy\",\n \"fields\": [\n \"title\",\n \"tags\"\n ]\n }\n }\n }\n }\n]\n\nUser Query: $Show $16 approved policies from IT Security department\n\nRephrased Query: Retrieve 16 approved policy documents of file type PDF from the IT Security department\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"hybrid_search_with_filters\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 16,\n \"from\": 0,\n \"query\": {\n \"hybrid\": {\n \"query\": \"approved policy\",\n \"fields\": [\n \"title\",\n \"tags\"\n ],\n \"filter\": {\n \"bool\": {\n \"must\": [\n {\n \"term\": {\n \"status\": \"approved\"\n }\n },\n {\n \"term\": {\n \"department\": \"IT Security\"\n }\n },\n {\n \"term\": {\n \"fileType\": \"pdf\"\n }\n }\n ]\n }\n }\n }\n }\n }\n}" } ]
{ "domain": "Legal Documents", "data_type": "unstructured", "query_type": "hybrid_search_with_filters", "pattern": "initial", "pattern_type": "complex_query", "size": 16, "from": 0, "is_pagination": false }