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: 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 duplicate payment on 2024-09-15.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"payment\",\n \"assignee\": \"john.doe\",\n \"createdAt\": \"2024-09-16T08:45:00Z\",\n \"price\": 250\n },\n {\n \"ticketId\": \"TXN-1002\",\n \"title\": \"Fraudulent transaction investigation\",\n \"description\": \"Suspicious transaction flagged for possible fraud.\",\n \"status\": \"in_progress\",\n \"priority\": \"critical\",\n \"category\": \"fraud\",\n \"assignee\": \"jane.smith\",\n \"createdAt\": \"2024-09-14T14:20:00Z\",\n \"price\": 1025.75\n },\n {\n \"ticketId\": \"TXN-1003\",\n \"title\": \"Monthly statement request\",\n \"description\": \"User requested the statement for March 2024.\",\n \"status\": \"resolved\",\n \"priority\": \"low\",\n \"category\": \"statement\",\n \"assignee\": \"alice.wang\",\n \"createdAt\": \"2024-09-10T09:10:00Z\",\n \"price\": 0\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"List high‑priority payment tickets assigned to John\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, fetching those 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 open 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_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": "Financial Transactions", "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: 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\": \"Advances in Quantum Computing\",\n \"author\": \"Dr. Alice Smith\",\n \"department\": \"Physics\",\n \"createdAt\": \"2023-11-15T09: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\": \"RP-002\",\n \"title\": \"Machine Learning for Healthcare\",\n \"author\": \"Prof. Bob Lee\",\n \"department\": \"Computer Science\",\n \"createdAt\": \"2024-02-20T14:45:00Z\",\n \"fileType\": \"docx\",\n \"status\": \"draft\",\n \"category\": \"research\",\n \"tags\": [\n \"machine learning\",\n \"healthcare\",\n \"AI\"\n ],\n \"confidentialityLevel\": \"internal\"\n },\n {\n \"documentId\": \"RP-003\",\n \"title\": \"Cybersecurity Policies 2024\",\n \"author\": \"Carol Nguyen\",\n \"department\": \"IT Security\",\n \"createdAt\": \"2024-01-10T08:00:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"policy\",\n \"tags\": [\n \"security\",\n \"policy\",\n \"remote work\"\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 latest tickets for you.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"List all 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 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": "research_papers", "data_type": "unstructured", "query_type": "listing", "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: 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-1001\",\n \"title\": \"Design login page\",\n \"description\": \"Create mockups and implement responsive design for the login page.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"UI/UX\",\n \"assignee\": \"alice\",\n \"createdAt\": \"2025-10-20T09:15:00Z\",\n \"price\": 1500\n },\n {\n \"ticketId\": \"TCK-1002\",\n \"title\": \"Database schema migration\",\n \"description\": \"Migrate user data to the new PostgreSQL schema with zero downtime.\",\n \"status\": \"in_progress\",\n \"priority\": \"medium\",\n \"category\": \"Backend\",\n \"assignee\": \"bob\",\n \"createdAt\": \"2025-10-18T14:30:00Z\",\n \"price\": 2500\n },\n {\n \"ticketId\": \"TCK-1003\",\n \"title\": \"Setup CI/CD pipeline\",\n \"description\": \"Configure Jenkins pipelines for automated testing and deployment.\",\n \"status\": \"closed\",\n \"priority\": \"low\",\n \"category\": \"DevOps\",\n \"assignee\": \"carol\",\n \"createdAt\": \"2025-09-30T11:45:00Z\",\n \"price\": 1200\n },\n {\n \"ticketId\": \"TCK-1004\",\n \"title\": \"Update project documentation\",\n \"description\": \"Revise the project wiki to reflect recent architectural changes.\",\n \"status\": \"open\",\n \"priority\": \"low\",\n \"category\": \"Documentation\",\n \"assignee\": \"dave\",\n \"createdAt\": \"2025-10-22T08:00:00Z\",\n \"price\": 500\n },\n {\n \"ticketId\": \"TCK-1005\",\n \"title\": \"Implement notification service\",\n \"description\": \"Develop a microservice to send email and push notifications.\",\n \"status\": \"in_progress\",\n \"priority\": \"high\",\n \"category\": \"Backend\",\n \"assignee\": \"eve\",\n \"createdAt\": \"2025-10-15T16:20:00Z\",\n \"price\": 3000\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\": \"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 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": "Project Management Tasks", "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: 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\": \"Contract renewal for Acme Supplies\",\n \"description\": \"Renewal of the annual supply contract with Acme Corp covering office stationery.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"procurement\",\n \"assignee\": \"jane.doe\",\n \"createdAt\": \"2025-10-20T09:15:00Z\",\n \"price\": 12500,\n \"documentContentWordsChunked\": [\n {\n \"passage\": \"Acme Supplies agreement renewal for fiscal year 2026.\",\n \"embedding\": [\n 0,\n 0,\n 0\n ]\n }\n ]\n },\n {\n \"ticketId\": \"TCK-1002\",\n \"productId\": \"PRD-2002\",\n \"title\": \"New contract for raw material purchase\",\n \"description\": \"Initial contract for purchasing raw steel from SteelWorks Ltd.\",\n \"status\": \"closed\",\n \"priority\": \"medium\",\n \"category\": \"materials\",\n \"assignee\": \"john.smith\",\n \"createdAt\": \"2025-09-15T14:30:00Z\",\n \"price\": 75000,\n \"documentContentWordsChunked\": [\n {\n \"passage\": \"SteelWorks Ltd. raw steel supply contract details.\",\n \"embedding\": [\n 0,\n 0,\n 0\n ]\n }\n ]\n },\n {\n \"ticketId\": \"TCK-1003\",\n \"productId\": \"PRD-2003\",\n \"title\": \"Service agreement with Logistics Co.\",\n \"description\": \"Annual logistics and transportation service agreement.\",\n \"status\": \"in_progress\",\n \"priority\": \"low\",\n \"category\": \"logistics\",\n \"assignee\": \"alice.wang\",\n \"createdAt\": \"2025-11-01T08:45:00Z\",\n \"price\": 34000,\n \"documentContentWordsChunked\": [\n {\n \"passage\": \"Logistics Co. service agreement for 2025-2026.\",\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\": \"Here are the most recent tickets from the Supplier Contracts index.\"\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: 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": "Supplier Contracts", "data_type": "structured", "query_type": "listing", "pattern": "initial", "pattern_type": "simple_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 2024\",\n \"author\": \"bob.johnson\",\n \"department\": \"IT Security\",\n \"createdAt\": \"2024-01-10T14:45:00Z\",\n \"fileType\": \"docx\",\n \"status\": \"approved\",\n \"category\": \"guideline\",\n \"tags\": [\n \"security\",\n \"guidelines\"\n ],\n \"confidentialityLevel\": \"internal\"\n },\n {\n \"documentId\": \"doc-003\",\n \"title\": \"Finance Department Quarterly Report Q3\",\n \"author\": \"carol.lee\",\n \"department\": \"Finance\",\n \"createdAt\": \"2024-07-05T11:20:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"draft\",\n \"category\": \"report\",\n \"tags\": [\n \"quarterly\",\n \"report\",\n \"finance\"\n ],\n \"confidentialityLevel\": \"confidential\"\n },\n {\n \"documentId\": \"doc-004\",\n \"title\": \"Company Blog: Enhancing Collaboration\",\n \"author\": \"david.kim\",\n \"department\": \"Marketing\",\n \"createdAt\": \"2024-03-22T08:15:00Z\",\n \"fileType\": \"html\",\n \"status\": \"published\",\n \"category\": \"blog\",\n \"tags\": [\n \"collaboration\",\n \"teamwork\"\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 ],\n \"confidentialityLevel\": \"public\"\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Can you list the latest blog posts about collaboration?\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, I will retrieve the most recent blog entries related to collaboration.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"Show all approved policies\",\n \"dsl_type\": \"match_all\",\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": "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 \"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 \"documentContentWords\": {\n \"type\": \"text\"\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-12T08:30:00Z\",\n \"price\": 125000,\n \"documentContentWordsChunked\": [\n {\n \"passage\": \"The supplier shall provide all necessary hardware and services for the network upgrade.\",\n \"embedding\": [\n 0,\n 0,\n 0\n ]\n }\n ],\n \"documentContentWords\": \"network upgrade hardware services supplier\"\n },\n {\n \"ticketId\": \"SC-1002\",\n \"productId\": \"PR-2002\",\n \"title\": \"Software Licensing Agreement\",\n \"description\": \"Annual licensing agreement for enterprise software suite.\",\n \"status\": \"resolved\",\n \"priority\": \"medium\",\n \"category\": \"software\",\n \"assignee\": \"legal_team\",\n \"createdAt\": \"2024-03-05T14:15:00Z\",\n \"price\": 75000,\n \"documentContentWordsChunked\": [\n {\n \"passage\": \"The license grants the supplier rights to use, modify, and distribute the software.\",\n \"embedding\": [\n 0,\n 0,\n 0\n ]\n }\n ],\n \"documentContentWords\": \"software licensing agreement annual\"\n },\n {\n \"ticketId\": \"SC-1003\",\n \"productId\": \"PR-2003\",\n \"title\": \"Maintenance Service Contract\",\n \"description\": \"Quarterly maintenance services for supplier's manufacturing equipment.\",\n \"status\": \"in_progress\",\n \"priority\": \"low\",\n \"category\": \"maintenance\",\n \"assignee\": \"operations\",\n \"createdAt\": \"2024-11-01T09:45:00Z\",\n \"price\": 30000,\n \"documentContentWordsChunked\": [\n {\n \"passage\": \"Maintenance includes routine inspections, parts replacement, and performance reporting.\",\n \"embedding\": [\n 0,\n 0,\n 0\n ]\n }\n ],\n \"documentContentWords\": \"maintenance quarterly inspections equipment\"\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\": \"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 open tickets\n\nRephrased Query: List all open 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_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": "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\": \"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 Impact Assessment\",\n \"author\": \"carol.lee\",\n \"department\": \"Legal\",\n \"createdAt\": \"2023-11-05T11:45:00Z\",\n \"fileType\": \"docx\",\n \"status\": \"approved\",\n \"category\": \"assessment\",\n \"tags\": [\n \"privacy\",\n \"data\",\n \"assessment\"\n ],\n \"confidentialityLevel\": \"restricted\"\n },\n {\n \"documentId\": \"RP-004\",\n \"title\": \"Machine Learning Research Overview\",\n \"author\": \"david.kumar\",\n \"department\": \"R&D\",\n \"createdAt\": \"2024-07-02T08:20:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"research\",\n \"tags\": [\n \"machine learning\",\n \"overview\"\n ],\n \"confidentialityLevel\": \"public\"\n },\n {\n \"documentId\": \"RP-005\",\n \"title\": \"IT Security Incident Response Plan\",\n \"author\": \"eva.martinez\",\n \"department\": \"IT Security\",\n \"createdAt\": \"2024-05-10T16:00: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 help me find the latest security policies?\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure! Are you looking for policies from a specific department or with a particular status?\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"List 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\": \"policy\"\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 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 \"text\": {\n \"field\": \"title\",\n \"query\": \"policy\"\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": "Research Papers", "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 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\": \"rev-001\",\n \"title\": \"Excellent Battery Life Review\",\n \"author\": \"alice.smith\",\n \"department\": \"Electronics\",\n \"createdAt\": \"2023-05-12T08:30:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"Smartphones\",\n \"tags\": [\n \"battery\",\n \"performance\"\n ],\n \"confidentialityLevel\": \"public\"\n },\n {\n \"documentId\": \"rev-002\",\n \"title\": \"Mixed Feelings on New Laptop Keyboard\",\n \"author\": \"bob.jones\",\n \"department\": \"Electronics\",\n \"createdAt\": \"2024-02-20T14:15:00Z\",\n \"fileType\": \"docx\",\n \"status\": \"pending\",\n \"category\": \"Laptops\",\n \"tags\": [\n \"keyboard\",\n \"usability\"\n ],\n \"confidentialityLevel\": \"internal\"\n },\n {\n \"documentId\": \"rev-003\",\n \"title\": \"Positive Feedback on Home Vacuum Cleaner\",\n \"author\": \"carol.lee\",\n \"department\": \"Home Appliances\",\n \"createdAt\": \"2023-11-03T10:45:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"Cleaning\",\n \"tags\": [\n \"vacuum\",\n \"performance\"\n ],\n \"confidentialityLevel\": \"public\"\n },\n {\n \"documentId\": \"rev-004\",\n \"title\": \"Critical Review of Budget Earbuds\",\n \"author\": \"dave.kumar\",\n \"department\": \"Electronics\",\n \"createdAt\": \"2024-01-15T09:00:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"rejected\",\n \"category\": \"Audio\",\n \"tags\": [\n \"sound\",\n \"price\"\n ],\n \"confidentialityLevel\": \"public\"\n },\n {\n \"documentId\": \"rev-005\",\n \"title\": \"User Experience Survey for Smart Thermostat\",\n \"author\": \"eva.martinez\",\n \"department\": \"Home Appliances\",\n \"createdAt\": \"2023-07-22T16:20:00Z\",\n \"fileType\": \"docx\",\n \"status\": \"approved\",\n \"category\": \"Smart Home\",\n \"tags\": [\n \"temperature\",\n \"automation\"\n ],\n \"confidentialityLevel\": \"internal\"\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Can you list the latest approved reviews for electronics?\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, I will retrieve approved reviews from the Electronics department.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"Show pending reviews from Laptops category\",\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"term\": {\n \"status\": \"pending\"\n }\n },\n {\n \"term\": {\n \"category\": \"Laptops\"\n }\n }\n ]\n }\n },\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n }\n }\n }\n]\n\nUser Query: Show approved reviews from Electronics department after 2023\n\nRephrased Query: Retrieve approved product reviews in the Electronics department with a creation date on or after 2023-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 \"match\": {\n \"title\": {\n \"query\": \"review\",\n \"operator\": \"and\"\n }\n }\n }\n ],\n \"filter\": {\n \"bool\": {\n \"must\": [\n {\n \"term\": {\n \"status\": \"approved\"\n }\n },\n {\n \"term\": {\n \"department\": \"Electronics\"\n }\n },\n {\n \"range\": {\n \"createdAt\": {\n \"gte\": \"2023-01-01T00:00:00Z\"\n }\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": "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: 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\": \"Order delay for product X\",\n \"description\": \"Customer reported a delay in receiving product X after placing the order on 2024-10-01.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"logistics\",\n \"assignee\": \"jane.doe\",\n \"createdAt\": \"2024-10-02T08:15:30Z\",\n \"price\": 1250.75,\n \"documentContentWordsChunked\": [\n {\n \"passage\": \"Order delay for product X reported by customer.\",\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\",\n \"description\": \"The invoice amount does not match the quoted price for order #12345.\",\n \"status\": \"in_progress\",\n \"priority\": \"medium\",\n \"category\": \"billing\",\n \"assignee\": \"john.smith\",\n \"createdAt\": \"2024-09-28T14:42:10Z\",\n \"price\": 980,\n \"documentContentWordsChunked\": [\n {\n \"passage\": \"Invoice discrepancy for order #12345.\",\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 price quote\",\n \"description\": \"Customer requests a price quote for bulk purchase of product Y.\",\n \"status\": \"closed\",\n \"priority\": \"low\",\n \"category\": \"sales\",\n \"assignee\": \"alice.wang\",\n \"createdAt\": \"2024-09-20T09:05:45Z\",\n \"price\": 0,\n \"documentContentWordsChunked\": [\n {\n \"passage\": \"Price quote request for bulk purchase of product Y.\",\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, I will list the most recent tickets for you.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"list 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\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": "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: 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\": \"Excellent Battery Life Review\",\n \"author\": \"alice\",\n \"department\": \"Electronics\",\n \"createdAt\": \"2024-03-15T10:22:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"Laptops\",\n \"tags\": [\n \"battery\",\n \"performance\"\n ],\n \"confidentialityLevel\": \"public\"\n },\n {\n \"documentId\": \"doc-002\",\n \"title\": \"Smartphone Camera Comparison\",\n \"author\": \"bob\",\n \"department\": \"Mobile\",\n \"createdAt\": \"2023-11-02T08:45:00Z\",\n \"fileType\": \"docx\",\n \"status\": \"pending\",\n \"category\": \"Smartphones\",\n \"tags\": [\n \"camera\",\n \"resolution\"\n ],\n \"confidentialityLevel\": \"internal\"\n },\n {\n \"documentId\": \"doc-003\",\n \"title\": \"Headphones Comfort Review\",\n \"author\": \"carol\",\n \"department\": \"Audio\",\n \"createdAt\": \"2024-07-20T14:10:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"Accessories\",\n \"tags\": [\n \"comfort\",\n \"sound quality\"\n ],\n \"confidentialityLevel\": \"public\"\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Can you list the approved product reviews from the Electronics department after 2024?\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, I will retrieve the approved reviews from Electronics created after January 1, 2024.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"Show pending reviews from Mobile department\",\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 \"filter\": {\n \"bool\": {\n \"must\": [\n {\n \"term\": {\n \"status\": \"pending\"\n }\n },\n {\n \"term\": {\n \"department\": \"Mobile\"\n }\n }\n ]\n }\n }\n }\n }\n }\n }\n]\n\nUser Query: Show approved reviews from Electronics department after 2024\n\nRephrased Query: List approved product reviews in the Electronics department with a creation date 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 \"vector\": {\n \"field\": \"documentContentWordsChunked.embedding\",\n \"query_vector\": [\n 0,\n 0,\n 0,\n \"...\"\n ],\n \"k\": 10\n },\n \"filter\": {\n \"bool\": {\n \"must\": [\n {\n \"term\": {\n \"status\": \"approved\"\n }\n },\n {\n \"term\": {\n \"department\": \"Electronics\"\n }\n },\n {\n \"range\": {\n \"createdAt\": {\n \"gte\": \"2024-01-01\"\n }\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": "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 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 \"documentContentWordsChunked\": []\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\": \"facility_team\",\n \"createdAt\": \"2025-09-15T14:42:10Z\",\n \"price\": 0,\n \"documentContentWordsChunked\": []\n },\n {\n \"ticketId\": \"TCK-1003\",\n \"title\": \"Software license renewal\",\n \"description\": \"Renewal needed for design software before end of month.\",\n \"status\": \"in_progress\",\n \"priority\": \"medium\",\n \"category\": \"software\",\n \"assignee\": \"procurement\",\n \"createdAt\": \"2025-10-05T11:00:00Z\",\n \"price\": 1200,\n \"documentContentWordsChunked\": []\n },\n {\n \"ticketId\": \"TCK-1004\",\n \"title\": \"Server disk space low\",\n \"description\": \"Primary database server running out of disk space.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"infrastructure\",\n \"assignee\": \"tech_support\",\n \"createdAt\": \"2025-10-22T09:30:45Z\",\n \"price\": 0,\n \"documentContentWordsChunked\": []\n },\n {\n \"ticketId\": \"TCK-1005\",\n \"title\": \"Email phishing attempt\",\n \"description\": \"Multiple users reported suspicious emails.\",\n \"status\": \"resolved\",\n \"priority\": \"medium\",\n \"category\": \"security\",\n \"assignee\": \"it_security\",\n \"createdAt\": \"2025-09-30T16:20:00Z\",\n \"price\": 0,\n \"documentContentWordsChunked\": []\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 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": "Inventory Tickets", "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: Product Catalog 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 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\": \"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\": \"2025-09-12T14:42:10Z\",\n \"price\": 1200\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\": \"facilities\",\n \"createdAt\": \"2025-11-01T09: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 in the system.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"List all closed 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 \"status\": \"closed\"\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 tickets assigned to tech support\n\nRephrased Query: List open tickets with high priority 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": "Product Catalog Tickets", "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: Customer Profiles\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-00123\",\n \"title\": \"Unable to access account dashboard\",\n \"description\": \"Customer reports that the dashboard page returns a 500 error after login.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"account\",\n \"assignee\": \"john.doe\",\n \"createdAt\": \"2025-10-20T14:32:10Z\",\n \"price\": 0,\n \"documentContentWordsChunked\": [\n {\n \"passage\": \"Customer reports that the dashboard page returns a 500 error after login.\",\n \"embedding\": [\n 0,\n 0,\n 0\n ]\n }\n ]\n },\n {\n \"ticketId\": \"TCKT-00456\",\n \"title\": \"Billing discrepancy for March invoice\",\n \"description\": \"Invoice shows $150 charge instead of the agreed $120.\",\n \"status\": \"closed\",\n \"priority\": \"medium\",\n \"category\": \"billing\",\n \"assignee\": \"jane.smith\",\n \"createdAt\": \"2025-03-15T09:12:45Z\",\n \"price\": 150,\n \"documentContentWordsChunked\": [\n {\n \"passage\": \"Invoice shows $150 charge instead of the agreed $120.\",\n \"embedding\": [\n 0,\n 0,\n 0\n ]\n }\n ]\n },\n {\n \"ticketId\": \"TCKT-00789\",\n \"title\": \"Feature request: Dark mode\",\n \"description\": \"Customer would like a dark mode option for the web UI.\",\n \"status\": \"open\",\n \"priority\": \"low\",\n \"category\": \"feature_request\",\n \"assignee\": \"alice.wang\",\n \"createdAt\": \"2025-11-01T17:45:30Z\",\n \"price\": 0,\n \"documentContentWordsChunked\": [\n {\n \"passage\": \"Customer would like a dark mode option for the web UI.\",\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 48 tickets from the customer profiles index.\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, I will retrieve the first 48 tickets without applying any filters.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"list 10 recent 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 me 48 tickets from the customer profiles index.\n\nRephrased Query: list 48 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\": 48,\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": "complex_query", "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: 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\": \"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 \"compliance\"\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:00:00Z\",\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\": \"2023-12-01T08:15: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, retrieving the requested 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 \"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": "Product Reviews", "data_type": "unstructured", "query_type": "listing_with_filters", "pattern": "refinement", "pattern_type": "change_sort", "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\": \"Patient Admission Form\",\n \"author\": \"Dr. Alice Smith\",\n \"department\": \"Cardiology\",\n \"createdAt\": \"2023-11-02T09:15:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"admission\",\n \"tags\": [\n \"patient\",\n \"admission\",\n \"cardiology\"\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-01-18T14:30:00Z\",\n \"fileType\": \"docx\",\n \"status\": \"review\",\n \"category\": \"imaging\",\n \"tags\": [\n \"xray\",\n \"report\",\n \"radiology\"\n ],\n \"confidentialityLevel\": \"medium\"\n },\n {\n \"documentId\": \"MR-003\",\n \"title\": \"Hospital Security Policy\",\n \"author\": \"IT Security Team\",\n \"department\": \"IT Security\",\n \"createdAt\": \"2024-03-05T08:00:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"policy\",\n \"tags\": [\n \"security\",\n \"policy\",\n \"hospital\"\n ],\n \"confidentialityLevel\": \"high\"\n },\n {\n \"documentId\": \"MR-004\",\n \"title\": \"Finance Department Budget 2024\",\n \"author\": \"Finance Office\",\n \"department\": \"Finance\",\n \"createdAt\": \"2024-02-20T11:45:00Z\",\n \"fileType\": \"xlsx\",\n \"status\": \"draft\",\n \"category\": \"budget\",\n \"tags\": [\n \"budget\",\n \"finance\",\n \"2024\"\n ],\n \"confidentialityLevel\": \"high\"\n },\n {\n \"documentId\": \"MR-005\",\n \"title\": \"Employee Remote Work Guidelines\",\n \"author\": \"HR Department\",\n \"department\": \"Human Resources\",\n \"createdAt\": \"2023-12-12T10:20:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"guidelines\",\n \"tags\": [\n \"remote work\",\n \"policy\",\n \"hr\"\n ],\n \"confidentialityLevel\": \"medium\"\n }\n]\n\nChat History:\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 all documents in the medical records index\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_all\": {}\n },\n {\n \"knn\": {\n \"field\": \"documentContentWordsChunked.embedding\",\n \"query_vector\": [\n 0,\n 0,\n 0,\n \"...\"\n ],\n \"k\": 10,\n \"num_candidates\": 100\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: 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 Campaign Launch\",\n \"description\": \"Prepare assets for the upcoming spring sale across all channels.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"campaign\",\n \"assignee\": \"alice\",\n \"createdAt\": \"2025-10-01T08:15:00Z\",\n \"price\": 0\n },\n {\n \"ticketId\": \"TCK-002\",\n \"productId\": \"PRD-1002\",\n \"title\": \"Email Newsletter Q4\",\n \"description\": \"Draft and schedule the Q4 newsletter for the email list.\",\n \"status\": \"in_progress\",\n \"priority\": \"medium\",\n \"category\": \"email\",\n \"assignee\": \"bob\",\n \"createdAt\": \"2025-09-20T11:30:00Z\",\n \"price\": 0\n },\n {\n \"ticketId\": \"TCK-003\",\n \"productId\": \"PRD-1003\",\n \"title\": \"Social Media Ads Review\",\n \"description\": \"Review performance of social media ads for the summer campaign.\",\n \"status\": \"resolved\",\n \"priority\": \"low\",\n \"category\": \"ads\",\n \"assignee\": \"carol\",\n \"createdAt\": \"2025-08-15T14:45:00Z\",\n \"price\": 0\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"List high-priority tickets assigned to Bob\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, fetching high‑priority tickets where assignee is Bob.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"List high-priority tickets assigned to Bob\",\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 \"assignee\": \"bob\"\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 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": "Marketing Campaigns", "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: 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\": \"2023-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\": \"Remote Work Guidelines\",\n \"author\": \"bob.johnson\",\n \"department\": \"Human Resources\",\n \"createdAt\": \"2024-01-10T14: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\": \"Data Encryption Standards\",\n \"author\": \"carol.lee\",\n \"department\": \"IT Security\",\n \"createdAt\": \"2022-11-05T11:20: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 \"documentId\": \"doc-004\",\n \"title\": \"Finance Department Budget Report 2024\",\n \"author\": \"david.kim\",\n \"department\": \"Finance\",\n \"createdAt\": \"2024-02-28T08:45:00Z\",\n \"fileType\": \"xlsx\",\n \"status\": \"approved\",\n \"category\": \"report\",\n \"tags\": [\n \"budget\",\n \"2024\",\n \"finance\"\n ],\n \"confidentialityLevel\": \"restricted\"\n },\n {\n \"documentId\": \"doc-005\",\n \"title\": \"Company-wide Security Awareness Training\",\n \"author\": \"eve.martin\",\n \"department\": \"IT Security\",\n \"createdAt\": \"2023-07-22T10:15:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"training\",\n \"tags\": [\n \"security\",\n \"awareness\",\n \"training\"\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 policies from the IT Security department.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"List 10 recent approved documents\",\n \"dsl_type\": \"simple_search\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"term\": {\n \"status\": \"approved\"\n }\n }\n ]\n }\n },\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n }\n }\n }\n]\n\nUser Query: Show 74 approved policies from IT Security\n\nRephrased Query: Retrieve 74 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\": 74,\n \"from\": 0,\n \"query\": {\n \"hybrid\": {\n \"query\": {\n \"semantic\": {\n \"field\": \"documentContentWordsChunked.passage\",\n \"query\": \"security 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 \"term\": {\n \"fileType\": \"pdf\"\n }\n }\n ]\n }\n }\n }\n }\n }\n}" } ]
{ "domain": "Corporate Blog Posts", "data_type": "unstructured", "query_type": "hybrid_search_with_filters", "pattern": "pagination", "pattern_type": "previous_page", "size": 74, "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: 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\": \"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 \"algorithm\"\n ],\n \"confidentialityLevel\": \"public\"\n },\n {\n \"documentId\": \"RP-002\",\n \"title\": \"Machine Learning for Healthcare\",\n \"author\": \"Prof. Bob 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 \"prediction\"\n ],\n \"confidentialityLevel\": \"internal\"\n },\n {\n \"documentId\": \"RP-003\",\n \"title\": \"Cybersecurity Policies 2024\",\n \"author\": \"Carol Nguyen\",\n \"department\": \"IT Security\",\n \"createdAt\": \"2024-03-08T11:00:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"policy\",\n \"tags\": [\n \"security\",\n \"policy\",\n \"remote work\"\n ],\n \"confidentialityLevel\": \"confidential\"\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 the most recent AI papers in the index.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"List all approved documents\",\n \"dsl_type\": \"match_all\",\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 \"bool\": {\n \"should\": [\n {\n \"knn\": {\n \"field\": \"documentContentWordsChunked.embedding\",\n \"query_vector\": [\n 0,\n 0,\n 0,\n \"...\"\n ],\n \"k\": 10,\n \"num_candidates\": 100\n }\n },\n {\n \"match_all\": {}\n }\n ],\n \"minimum_should_match\": 1\n }\n }\n }\n}" } ]
{ "domain": "Research Papers", "data_type": "unstructured", "query_type": "hybrid_search", "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: 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.jones\",\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 Quarterly Report Q1 2024\",\n \"author\": \"carol.lee\",\n \"department\": \"Finance\",\n \"createdAt\": \"2024-04-20T11:00:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"report\",\n \"tags\": [\n \"finance\",\n \"quarterly\",\n \"2024\"\n ],\n \"confidentialityLevel\": \"confidential\"\n },\n {\n \"documentId\": \"doc-004\",\n \"title\": \"Data Privacy Policy\",\n \"author\": \"david.kim\",\n \"department\": \"Legal\",\n \"createdAt\": \"2023-12-10T08:45:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"policy\",\n \"tags\": [\n \"privacy\",\n \"data\",\n \"compliance\"\n ],\n \"confidentialityLevel\": \"internal\"\n },\n {\n \"documentId\": \"doc-005\",\n \"title\": \"IT Security Incident Response Procedure\",\n \"author\": \"eve.wong\",\n \"department\": \"IT Security\",\n \"createdAt\": \"2024-07-02T10: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 show me the latest security policies?\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, here are the most recent approved security policies from the IT Security department.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"List 10 recent blog posts about security\",\n \"dsl_type\": \"semantic_search\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"match\": {\n \"title\": \"security\"\n }\n },\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n }\n }\n }\n]\n\nUser Query: Show 16 approved policies from IT Security\n\nRephrased Query: Retrieve 16 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\": 16,\n \"from\": 0,\n \"query\": {\n \"hybrid\": {\n \"text\": \"approved policies\",\n \"embedding\": {\n \"vector\": [\n 0,\n 0,\n 0,\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": "Corporate Blog Posts", "data_type": "unstructured", "query_type": "hybrid_search_with_filters", "pattern": "initial", "pattern_type": "filtered_search", "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: 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 Security Update\",\n \"author\": \"alice.smith\",\n \"department\": \"IT Security\",\n \"createdAt\": \"2024-09-15T08: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\": \"doc-002\",\n \"title\": \"Remote Work Guidelines\",\n \"author\": \"bob.johnson\",\n \"department\": \"Human Resources\",\n \"createdAt\": \"2024-08-01T12: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\": \"Annual Financial Report 2024\",\n \"author\": \"carol.lee\",\n \"department\": \"Finance\",\n \"createdAt\": \"2024-07-20T09:45:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"published\",\n \"category\": \"report\",\n \"tags\": [\n \"finance\",\n \"annual\",\n \"2024\"\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\": \"Here are the latest tickets from 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 \"_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 the latest 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\": 10,\n \"query\": {\n \"match_all\": {}\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n}" } ]
{ "domain": "News Articles", "data_type": "unstructured", "query_type": "listing", "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: 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\": \"Electronics\",\n \"createdAt\": \"2024-03-12T09:15:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"Audio\",\n \"tags\": [\n \"wireless\",\n \"battery\",\n \"sound quality\"\n ],\n \"confidentialityLevel\": \"public\"\n },\n {\n \"documentId\": \"PR-002\",\n \"title\": \"Smartphone Camera Benchmark\",\n \"author\": \"bob.jones\",\n \"department\": \"Mobile\",\n \"createdAt\": \"2024-05-08T14:30:00Z\",\n \"fileType\": \"docx\",\n \"status\": \"approved\",\n \"category\": \"Photography\",\n \"tags\": [\n \"resolution\",\n \"low light\",\n \"stabilization\"\n ],\n \"confidentialityLevel\": \"public\"\n },\n {\n \"documentId\": \"PR-003\",\n \"title\": \"Laptop Battery Life Comparison\",\n \"author\": \"carla.lee\",\n \"department\": \"Computers\",\n \"createdAt\": \"2024-01-20T11:45:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"Performance\",\n \"tags\": [\n \"battery\",\n \"runtime\",\n \"efficiency\"\n ],\n \"confidentialityLevel\": \"public\"\n },\n {\n \"documentId\": \"PR-004\",\n \"title\": \"Smartwatch Health Feature Review\",\n \"author\": \"david.kim\",\n \"department\": \"Wearables\",\n \"createdAt\": \"2024-04-02T08:20:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"Health\",\n \"tags\": [\n \"heart rate\",\n \"sleep tracking\",\n \"notifications\"\n ],\n \"confidentialityLevel\": \"public\"\n },\n {\n \"documentId\": \"PR-005\",\n \"title\": \"Gaming Console Performance Analysis\",\n \"author\": \"emma.wong\",\n \"department\": \"Gaming\",\n \"createdAt\": \"2024-02-15T16:05:00Z\",\n \"fileType\": \"docx\",\n \"status\": \"approved\",\n \"category\": \"Performance\",\n \"tags\": [\n \"fps\",\n \"latency\",\n \"graphics\"\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 audio product reviews?\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure! Here are the key points from the most recent audio reviews...\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"Show 10 recent approved reviews\",\n \"dsl_type\": \"semantic_search\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"match_all\": {}\n }\n }\n }\n]\n\nUser Query: Show 35 approved product review documents from the Electronics department\n\nRephrased Query: Retrieve 35 approved product review documents 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\": 35,\n \"from\": 0,\n \"query\": {\n \"bool\": {\n \"should\": [\n {\n \"match_all\": {}\n },\n {\n \"knn\": {\n \"field\": \"documentContentWordsChunked.embedding\",\n \"query_vector\": [\n 0,\n 0,\n \"...\"\n ],\n \"k\": 35,\n \"num_candidates\": 100\n }\n }\n ],\n \"minimum_should_match\": 1\n }\n }\n }\n}" } ]
{ "domain": "Product Reviews", "data_type": "unstructured", "query_type": "hybrid_search", "pattern": "initial", "pattern_type": "semantic_question", "size": 35, "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-001\",\n \"productId\": \"PRD-1001\",\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 {\n \"ticketId\": \"TCKT-002\",\n \"productId\": \"PRD-2002\",\n \"title\": \"Invoice discrepancy\",\n \"description\": \"The total amount on the invoice does not match the order total.\",\n \"status\": \"resolved\",\n \"priority\": \"medium\",\n \"category\": \"billing\",\n \"assignee\": \"finance_team\",\n \"createdAt\": \"2025-09-12T14:42:10Z\",\n \"price\": 1250.75,\n \"documentContentWordsChunked\": []\n },\n {\n \"ticketId\": \"TCKT-003\",\n \"productId\": \"PRD-3003\",\n \"title\": \"Software installation failure\",\n \"description\": \"Installation script aborts with error code 42 on Windows 11.\",\n \"status\": \"in_progress\",\n \"priority\": \"low\",\n \"category\": \"software\",\n \"assignee\": \"dev_ops\",\n \"createdAt\": \"2025-11-01T09:05:00Z\",\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\": \"Sure, here are the most recent tickets.\"\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 }\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": "Sales Orders", "data_type": "structured", "query_type": "listing", "pattern": "initial", "pattern_type": "simple_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 corporate VPN.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"network\",\n \"assignee\": \"tech_support\",\n \"createdAt\": \"2025-10-20T08:15:30Z\",\n \"price\": 1250,\n \"documentContentWordsChunked\": [\n {\n \"passage\": \"The VPN tunnel experiences packet loss during peak hours.\",\n \"embedding\": [\n 0,\n 0,\n 0\n ]\n }\n ]\n },\n {\n \"ticketId\": \"SO-1002\",\n \"productId\": \"PR-2002\",\n \"title\": \"Software license renewal\",\n \"description\": \"Renewal of enterprise software license for Q4.\",\n \"status\": \"closed\",\n \"priority\": \"medium\",\n \"category\": \"account\",\n \"assignee\": \"account_manager\",\n \"createdAt\": \"2025-09-15T14:42:10Z\",\n \"price\": 5400,\n \"documentContentWordsChunked\": [\n {\n \"passage\": \"License renewal includes additional modules for analytics.\",\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\": \"Replace faulty SSD in server rack 12.\",\n \"status\": \"in_progress\",\n \"priority\": \"high\",\n \"category\": \"hardware\",\n \"assignee\": \"field_engineer\",\n \"createdAt\": \"2025-10-05T11:07:45Z\",\n \"price\": 320.75,\n \"documentContentWordsChunked\": [\n {\n \"passage\": \"SSD model XYZ123 has reported read errors.\",\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 the latest tickets.\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, here are the most recent tickets sorted by creation date.\"\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 \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n }\n]\n\nUser Query: List 40 high-priority network tickets assigned to tech support\n\nRephrased Query: Retrieve 40 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\": 40,\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": "Sales Orders", "data_type": "structured", "query_type": "listing_with_filters", "pattern": "initial", "pattern_type": "sorted_listing", "size": 40, "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\": \"Global Economic Outlook 2025\",\n \"author\": \"Jane Doe\",\n \"department\": \"Finance\",\n \"createdAt\": \"2024-11-01T08:30:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"published\",\n \"category\": \"Economy\",\n \"tags\": [\n \"forecast\",\n \"global\",\n \"2025\"\n ],\n \"confidentialityLevel\": \"public\"\n },\n {\n \"documentId\": \"doc-002\",\n \"title\": \"Tech Innovations in AI\",\n \"author\": \"John Smith\",\n \"department\": \"Research\",\n \"createdAt\": \"2024-09-15T14:12:00Z\",\n \"fileType\": \"docx\",\n \"status\": \"draft\",\n \"category\": \"Technology\",\n \"tags\": [\n \"AI\",\n \"innovation\",\n \"machine learning\"\n ],\n \"confidentialityLevel\": \"internal\"\n },\n {\n \"documentId\": \"doc-003\",\n \"title\": \"Local Election Results\",\n \"author\": \"Emily Clark\",\n \"department\": \"Newsroom\",\n \"createdAt\": \"2024-10-20T19:45:00Z\",\n \"fileType\": \"html\",\n \"status\": \"published\",\n \"category\": \"Politics\",\n \"tags\": [\n \"election\",\n \"local\",\n \"results\"\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\": \"Sure, I will retrieve 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 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\": \"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 \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"should\": [\n {\n \"knn\": {\n \"documentContentWordsChunked.embedding\": {\n \"vector\": [\n 0,\n 0,\n 0\n ],\n \"k\": 10\n }\n }\n }\n ]\n }\n }\n }\n}" } ]
{ "domain": "News Articles", "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: customer_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.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"network\",\n \"assignee\": \"tech_support\",\n \"createdAt\": \"2024-10-01T08:15:30Z\",\n \"price\": 0,\n \"documentContentWordsChunked\": []\n },\n {\n \"ticketId\": \"TCKT-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\": \"2024-09-20T14:42:10Z\",\n \"price\": 1200,\n \"documentContentWordsChunked\": []\n },\n {\n \"ticketId\": \"TCKT-003\",\n \"title\": \"Printer malfunction on 2nd floor\",\n \"description\": \"Paper jam recurring after every print job.\",\n \"status\": \"in_progress\",\n \"priority\": \"low\",\n \"category\": \"hardware\",\n \"assignee\": \"it_support\",\n \"createdAt\": \"2024-10-05T11:05:45Z\",\n \"price\": 0,\n \"documentContentWordsChunked\": []\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"List tickets\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, here are the tickets you requested.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"List 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": "customer_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: E-commerce 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\": \"2025-10-20T08:15:30Z\",\n \"price\": 199.99,\n \"documentContentWordsChunked\": [\n {\n \"passage\": \"Wireless headphones with premium sound quality.\",\n \"embedding\": [\n 0,\n 0,\n \"...\"\n ]\n }\n ]\n },\n {\n \"productId\": \"P1002\",\n \"title\": \"Ergonomic Office Chair\",\n \"description\": \"Adjustable lumbar support, breathable mesh back, and 360Β° swivel.\",\n \"status\": \"available\",\n \"priority\": \"medium\",\n \"category\": \"furniture\",\n \"assignee\": \"logistics_team\",\n \"createdAt\": \"2025-10-18T14:02:10Z\",\n \"price\": 149.5,\n \"documentContentWordsChunked\": [\n {\n \"passage\": \"Comfortable office chair for long work hours.\",\n \"embedding\": [\n 0,\n 0,\n \"...\"\n ]\n }\n ]\n },\n {\n \"productId\": \"P1003\",\n \"title\": \"Stainless Steel Water Bottle\",\n \"description\": \"1‑liter insulated bottle, keeps drinks cold for 24β€―h and hot for 12β€―h.\",\n \"status\": \"out_of_stock\",\n \"priority\": \"low\",\n \"category\": \"accessories\",\n \"assignee\": \"supply_chain\",\n \"createdAt\": \"2025-10-15T09:45:00Z\",\n \"price\": 29.99,\n \"documentContentWordsChunked\": [\n {\n \"passage\": \"Eco‑friendly reusable water bottle.\",\n \"embedding\": [\n 0,\n 0,\n \"...\"\n ]\n }\n ]\n },\n {\n \"productId\": \"P1004\",\n \"title\": \"Smart Home Hub\",\n \"description\": \"Control lights, thermostats, and security cameras from a single app.\",\n \"status\": \"available\",\n \"priority\": \"high\",\n \"category\": \"smart_home\",\n \"assignee\": \"tech_support\",\n \"createdAt\": \"2025-10-22T11:30:45Z\",\n \"price\": 89,\n \"documentContentWordsChunked\": [\n {\n \"passage\": \"Central hub for all smart devices.\",\n \"embedding\": [\n 0,\n 0,\n \"...\"\n ]\n }\n ]\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Show me the newest products in the catalog.\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Here are the latest items added to the catalog, sorted by creation date.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"List 10 recent products\",\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 17 latest products\n\nRephrased Query: list 17 products 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\": 17,\n \"from\": 0,\n \"query\": {\n \"match_all\": {}\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n}" } ]
{ "domain": "E-commerce Product Catalog", "data_type": "structured", "query_type": "listing", "pattern": "initial", "pattern_type": "sorted_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: 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 \"documentContentWords\": {\n \"type\": \"text\"\n }\n }\n}\n\nSample Documents:\n[\n {\n \"ticketId\": \"TCK-1001\",\n \"title\": \"Design login page\",\n \"description\": \"Create mockups and implement responsive login UI for the new app.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"design\",\n \"assignee\": \"alice\",\n \"createdAt\": \"2024-10-01T09:15:00Z\",\n \"price\": 1500,\n \"documentContentWordsChunked\": [\n {\n \"passage\": \"Design login page mockups\",\n \"embedding\": [\n 0,\n 0,\n \"...\"\n ]\n }\n ],\n \"documentContentWords\": \"design login page mockups responsive ui\"\n },\n {\n \"ticketId\": \"TCK-1002\",\n \"title\": \"Setup CI/CD pipeline\",\n \"description\": \"Configure Jenkins pipelines for automated build, test, and deployment.\",\n \"status\": \"in_progress\",\n \"priority\": \"medium\",\n \"category\": \"devops\",\n \"assignee\": \"bob\",\n \"createdAt\": \"2024-09-28T14:30:00Z\",\n \"price\": 2000,\n \"documentContentWordsChunked\": [\n {\n \"passage\": \"Configure Jenkins pipelines\",\n \"embedding\": [\n 0,\n 0,\n \"...\"\n ]\n }\n ],\n \"documentContentWords\": \"configure jenkins pipelines automated build test deployment\"\n },\n {\n \"ticketId\": \"TCK-1003\",\n \"title\": \"Update project budget\",\n \"description\": \"Revise the budget spreadsheet to reflect Q4 expenses and forecast.\",\n \"status\": \"closed\",\n \"priority\": \"low\",\n \"category\": \"finance\",\n \"assignee\": \"carol\",\n \"createdAt\": \"2024-09-15T11:45:00Z\",\n \"price\": 500,\n \"documentContentWordsChunked\": [\n {\n \"passage\": \"Revise budget spreadsheet\",\n \"embedding\": [\n 0,\n 0,\n \"...\"\n ]\n }\n ],\n \"documentContentWords\": \"revise budget spreadsheet q4 expenses forecast\"\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 }\n }\n]\n\nUser Query: Show tickets\n\nRephrased Query: List all 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": "project_management_tasks", "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: 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-09-12T08:15:30Z\",\n \"price\": 1299.99,\n \"documentContentWordsChunked\": [\n {\n \"passage\": \"This router supports up to 10 Gbps throughput.\",\n \"embedding\": [\n 0,\n 0,\n 0\n ]\n }\n ]\n },\n {\n \"productId\": \"P-1002\",\n \"title\": \"Secure VPN Appliance\",\n \"description\": \"Appliance providing secure site‑to‑site VPN connections.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"network\",\n \"assignee\": \"tech_support\",\n \"createdAt\": \"2024-09-10T14:42:10Z\",\n \"price\": 799.5,\n \"documentContentWordsChunked\": [\n {\n \"passage\": \"Features include AES‑256 encryption and dual‑WAN failover.\",\n \"embedding\": [\n 0,\n 0,\n 0\n ]\n }\n ]\n },\n {\n \"productId\": \"P-1003\",\n \"title\": \"Cloud Storage Subscription\",\n \"description\": \"Annual subscription for 5β€―TB of cloud storage.\",\n \"status\": \"closed\",\n \"priority\": \"medium\",\n \"category\": \"storage\",\n \"assignee\": \"sales_team\",\n \"createdAt\": \"2024-08-20T09:05:45Z\",\n \"price\": 499,\n \"documentContentWordsChunked\": [\n {\n \"passage\": \"Includes unlimited data transfer within the same region.\",\n \"embedding\": [\n 0,\n 0,\n 0\n ]\n }\n ]\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Can you show me the latest tickets?\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, here are the most recent tickets in the system.\"\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: List 49 high-priority network tickets assigned to tech support\n\nRephrased Query: Retrieve 49 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\": 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": "product_catalog", "data_type": "structured", "query_type": "listing_with_filters", "pattern": "initial", "pattern_type": "keyword_search", "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: 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 \"priority\": {\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\": \"Password Reset Request\",\n \"author\": \"alice@example.com\",\n \"department\": \"IT\",\n \"createdAt\": \"2024-03-15T09:12:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"open\",\n \"category\": \"authentication\",\n \"tags\": [\n \"password\",\n \"reset\"\n ],\n \"confidentialityLevel\": \"internal\",\n \"priority\": \"high\"\n },\n {\n \"documentId\": \"TCK-002\",\n \"title\": \"Invoice Dispute\",\n \"author\": \"bob@example.com\",\n \"department\": \"Finance\",\n \"createdAt\": \"2024-04-02T14:45:00Z\",\n \"fileType\": \"docx\",\n \"status\": \"closed\",\n \"category\": \"billing\",\n \"tags\": [\n \"invoice\",\n \"dispute\"\n ],\n \"confidentialityLevel\": \"confidential\",\n \"priority\": \"medium\"\n },\n {\n \"documentId\": \"TCK-003\",\n \"title\": \"VPN Access Issue\",\n \"author\": \"carol@example.com\",\n \"department\": \"IT\",\n \"createdAt\": \"2024-05-20T11:30:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"in_progress\",\n \"category\": \"network\",\n \"tags\": [\n \"vpn\",\n \"access\"\n ],\n \"confidentialityLevel\": \"internal\",\n \"priority\": \"low\"\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"List all open tickets from IT department.\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, here are the open tickets from the IT department...\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"List all closed tickets from Finance after 2024-01-01\",\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\": \"closed\"\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 \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n }\n }\n }\n]\n\nUser Query: Show high priority open tickets from IT department\n\nRephrased Query: Retrieve open tickets in the IT department with priority high\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 \"status\": \"open\"\n }\n },\n {\n \"term\": {\n \"department\": \"IT\"\n }\n },\n {\n \"term\": {\n \"priority\": \"high\"\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": "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: Corporate 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\": \"POL-001\",\n \"title\": \"IT Security Remote Work Policy\",\n \"author\": \"alice.smith\",\n \"department\": \"IT Security\",\n \"createdAt\": \"2023-11-15\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"policy\",\n \"tags\": [\n \"remote\",\n \"security\"\n ],\n \"confidentialityLevel\": \"internal\"\n },\n {\n \"documentId\": \"POL-002\",\n \"title\": \"Finance Expense Reimbursement Guidelines\",\n \"author\": \"bob.jones\",\n \"department\": \"Finance\",\n \"createdAt\": \"2024-02-10\",\n \"fileType\": \"pdf\",\n \"status\": \"draft\",\n \"category\": \"guideline\",\n \"tags\": [\n \"expense\",\n \"reimbursement\"\n ],\n \"confidentialityLevel\": \"confidential\"\n },\n {\n \"documentId\": \"POL-003\",\n \"title\": \"HR Employee Onboarding Checklist\",\n \"author\": \"carol.lee\",\n \"department\": \"Human Resources\",\n \"createdAt\": \"2022-07-01\",\n \"fileType\": \"docx\",\n \"status\": \"approved\",\n \"category\": \"procedure\",\n \"tags\": [\n \"onboarding\",\n \"new hire\"\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 \"text_expansion\": {\n \"model_id\": \"semantic-model\",\n \"model_text\": \"finance pdf documents\"\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 \"gte\": \"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: 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 \"queries\": [\n {\n \"text_expansion\": {\n \"model_id\": \"semantic-model\",\n \"model_text\": \"approved policies IT Security\"\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": "Corporate Policies", "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: 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\": \"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\": \"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 Quarterly Report Q1 2024\",\n \"author\": \"carol.lee\",\n \"department\": \"Finance\",\n \"createdAt\": \"2024-04-20T08:15:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"report\",\n \"tags\": [\n \"finance\",\n \"quarterly\",\n \"2024\"\n ],\n \"confidentialityLevel\": \"confidential\"\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"List all draft documents in Human Resources.\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, fetching draft documents from the Human Resources department.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"List all draft documents in Human Resources.\",\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\": \"Human Resources\"\n }\n },\n {\n \"term\": {\n \"status\": \"draft\"\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 \"queries\": [\n {\n \"semantic\": {\n \"field\": \"documentContentWordsChunked.passage\",\n \"query\": \"policy\",\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"field\": \"documentContentWordsChunked.embedding\",\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": "BlogPosts", "data_type": "unstructured", "query_type": "hybrid_search_with_filters", "pattern": "refinement", "pattern_type": "change_sort", "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\": \"Design login page\",\n \"description\": \"Create mockups and implement the login UI for the new web app.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"design\",\n \"assignee\": \"alice\",\n \"createdAt\": \"2025-10-20T09:15:00Z\",\n \"price\": 0,\n \"documentContentWordsChunked\": []\n },\n {\n \"ticketId\": \"TCK-002\",\n \"title\": \"Setup CI/CD pipeline\",\n \"description\": \"Configure Jenkins pipelines for automated builds and deployments.\",\n \"status\": \"in_progress\",\n \"priority\": \"medium\",\n \"category\": \"devops\",\n \"assignee\": \"bob\",\n \"createdAt\": \"2025-10-18T14:30:00Z\",\n \"price\": 0,\n \"documentContentWordsChunked\": []\n },\n {\n \"ticketId\": \"TCK-003\",\n \"title\": \"Update project budget\",\n \"description\": \"Revise the budget spreadsheet to reflect Q4 expenses.\",\n \"status\": \"closed\",\n \"priority\": \"low\",\n \"category\": \"finance\",\n \"assignee\": \"carol\",\n \"createdAt\": \"2025-09-30T11:45:00Z\",\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 latest tickets from the project management index.\"\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: 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": "Project Management Tasks", "data_type": "structured", "query_type": "listing", "pattern": "refinement", "pattern_type": "change_sort", "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\": \"post-001\",\n \"title\": \"Understanding Zero Trust Security\",\n \"author\": \"alice.smith\",\n \"department\": \"IT Security\",\n \"createdAt\": \"2024-03-12T09:15:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"Security\",\n \"tags\": [\n \"zero-trust\",\n \"network\",\n \"policy\"\n ],\n \"confidentialityLevel\": \"public\"\n },\n {\n \"documentId\": \"post-002\",\n \"title\": \"Remote Work Best Practices\",\n \"author\": \"bob.jones\",\n \"department\": \"Human Resources\",\n \"createdAt\": \"2024-05-08T14:30:00Z\",\n \"fileType\": \"docx\",\n \"status\": \"draft\",\n \"category\": \"Productivity\",\n \"tags\": [\n \"remote\",\n \"collaboration\",\n \"tools\"\n ],\n \"confidentialityLevel\": \"internal\"\n },\n {\n \"documentId\": \"post-003\",\n \"title\": \"Quarterly Financial Overview\",\n \"author\": \"carol.lee\",\n \"department\": \"Finance\",\n \"createdAt\": \"2024-07-01T11:00:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"Finance\",\n \"tags\": [\n \"Q2\",\n \"revenue\",\n \"expenses\"\n ],\n \"confidentialityLevel\": \"confidential\"\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, retrieving the most recent blog posts for you.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"list blog posts\",\n \"dsl_type\": \"hybrid_search\",\n \"dsl_query\": {\n \"size\": 10,\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 \"...\"\n ],\n \"k\": 10\n }\n }\n }\n ]\n }\n }\n }\n }\n]\n\nUser Query: Show me the blog posts\n\nRephrased Query: Retrieve 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\": 10,\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 }\n }\n }\n}" } ]
{ "domain": "BlogPosts", "data_type": "unstructured", "query_type": "hybrid_search", "pattern": "pagination", "pattern_type": "more_results", "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: 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\": \"INV-001\",\n \"title\": \"Network Router\",\n \"description\": \"High‑performance router for 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 },\n {\n \"productId\": \"INV-002\",\n \"title\": \"Server Blade\",\n \"description\": \"Blade server with 32 cores and 256β€―GB RAM.\",\n \"status\": \"closed\",\n \"priority\": \"medium\",\n \"category\": \"hardware\",\n \"assignee\": \"infrastructure team\",\n \"createdAt\": \"2024-09-05T14:42:10Z\",\n \"price\": 7499\n },\n {\n \"productId\": \"INV-003\",\n \"title\": \"Firewall Appliance\",\n \"description\": \"Next‑gen firewall with intrusion prevention.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"network\",\n \"assignee\": \"tech support\",\n \"createdAt\": \"2024-11-01T11:07:45Z\",\n \"price\": 2199.5\n },\n {\n \"productId\": \"INV-004\",\n \"title\": \"Laptop Pro 15\\\"\",\n \"description\": \"Business laptop with 16β€―GB RAM and SSD storage.\",\n \"status\": \"in_progress\",\n \"priority\": \"low\",\n \"category\": \"hardware\",\n \"assignee\": \"procurement\",\n \"createdAt\": \"2024-08-20T09:30:00Z\",\n \"price\": 1499\n },\n {\n \"productId\": \"INV-005\",\n \"title\": \"Switch 48‑Port\",\n \"description\": \"Managed Ethernet switch for data center.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"network\",\n \"assignee\": \"tech support\",\n \"createdAt\": \"2024-10-28T16:22:18Z\",\n \"price\": 899.75\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Can you show me the latest open tickets?\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, here are the most recent open tickets sorted by creation date.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"List 10 recent 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 me 24 high‑priority network tickets assigned to tech support\n\nRephrased Query: Retrieve 24 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\": 24,\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": "filtered_search", "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: 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\": \"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-001\",\n \"title\": \"Network outage in data center\",\n \"description\": \"Investigate and resolve the network outage affecting servers.\",\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 roadmap\",\n \"description\": \"Add Q4 milestones to the project roadmap document.\",\n \"status\": \"in_progress\",\n \"priority\": \"medium\",\n \"category\": \"planning\",\n \"assignee\": \"product_manager\",\n \"createdAt\": \"2025-09-15T14:30:00Z\",\n \"price\": 0\n },\n {\n \"ticketId\": \"TCK-003\",\n \"title\": \"Bug fix: login timeout\",\n \"description\": \"Resolve the timeout error occurring during user login.\",\n \"status\": \"resolved\",\n \"priority\": \"high\",\n \"category\": \"bug\",\n \"assignee\": \"dev_team\",\n \"createdAt\": \"2025-08-05T10:45:00Z\",\n \"price\": 0\n },\n {\n \"ticketId\": \"TCK-004\",\n \"title\": \"Prepare financial report Q3\",\n \"description\": \"Compile and review the financial performance for Q3.\",\n \"status\": \"open\",\n \"priority\": \"low\",\n \"category\": \"finance\",\n \"assignee\": \"accounting\",\n \"createdAt\": \"2025-10-01T09:00:00Z\",\n \"price\": 0\n },\n {\n \"ticketId\": \"TCK-005\",\n \"title\": \"Server patch deployment\",\n \"description\": \"Deploy security patches to all production servers.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"maintenance\",\n \"assignee\": \"tech_support\",\n \"createdAt\": \"2025-10-18T11: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\": \"Here are the latest tickets from the system.\"\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 \"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: List high-priority network tickets assigned to tech support\n\nRephrased Query: Retrieve 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 \"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": "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: 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\": \"Global Economic Outlook 2025\",\n \"author\": \"Jane Smith\",\n \"department\": \"Finance\",\n \"createdAt\": \"2024-11-01T08:30:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"published\",\n \"category\": \"Economy\",\n \"tags\": [\n \"economy\",\n \"forecast\",\n \"2025\"\n ],\n \"confidentialityLevel\": \"public\"\n },\n {\n \"documentId\": \"doc-002\",\n \"title\": \"Cybersecurity Best Practices for Remote Workers\",\n \"author\": \"Alan Chen\",\n \"department\": \"IT Security\",\n \"createdAt\": \"2024-09-15T14:12:00Z\",\n \"fileType\": \"docx\",\n \"status\": \"approved\",\n \"category\": \"Security\",\n \"tags\": [\n \"cybersecurity\",\n \"remote work\",\n \"policy\"\n ],\n \"confidentialityLevel\": \"internal\"\n },\n {\n \"documentId\": \"doc-003\",\n \"title\": \"Annual Climate Report 2024\",\n \"author\": \"Maria Gonzalez\",\n \"department\": \"Environment\",\n \"createdAt\": \"2024-10-20T10:45:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"published\",\n \"category\": \"Environment\",\n \"tags\": [\n \"climate\",\n \"report\",\n \"2024\"\n ],\n \"confidentialityLevel\": \"public\"\n },\n {\n \"documentId\": \"doc-004\",\n \"title\": \"Company HR Policies Update\",\n \"author\": \"Liam Patel\",\n \"department\": \"Human Resources\",\n \"createdAt\": \"2024-08-05T09:00:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"HR\",\n \"tags\": [\n \"policy\",\n \"HR\",\n \"update\"\n ],\n \"confidentialityLevel\": \"internal\"\n },\n {\n \"documentId\": \"doc-005\",\n \"title\": \"Tech Innovation Trends 2024\",\n \"author\": \"Sofia Rossi\",\n \"department\": \"Research\",\n \"createdAt\": \"2024-07-22T16:20:00Z\",\n \"fileType\": \"docx\",\n \"status\": \"draft\",\n \"category\": \"Technology\",\n \"tags\": [\n \"innovation\",\n \"technology\",\n \"2024\"\n ],\n \"confidentialityLevel\": \"confidential\"\n }\n]\n\nChat History:\n[]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"List recent finance reports\",\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 \"should\": [\n {\n \"knn\": {\n \"documentContentWordsChunked.embedding\": {\n \"vector\": [\n 0,\n 0,\n 0,\n \"...\"\n ],\n \"k\": 10\n }\n }\n }\n ]\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\": \"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 \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"should\": [\n {\n \"knn\": {\n \"documentContentWordsChunked.embedding\": {\n \"vector\": [\n 0,\n 0,\n 0,\n \"...\"\n ],\n \"k\": 10\n }\n }\n }\n ]\n }\n }\n }\n}" } ]
{ "domain": "News Articles", "data_type": "unstructured", "query_type": "hybrid_search", "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: 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 \"supplierName\": {\n \"type\": \"keyword\"\n },\n \"startDate\": {\n \"type\": \"date\"\n },\n \"endDate\": {\n \"type\": \"date\"\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\": \"Network Infrastructure Upgrade\",\n \"description\": \"Upgrade of core network switches for supplier XYZ.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"network\",\n \"assignee\": \"tech support\",\n \"createdAt\": \"2024-09-12T08:15:30Z\",\n \"price\": 125000,\n \"supplierName\": \"XYZ Telecom\",\n \"startDate\": \"2024-10-01\",\n \"endDate\": \"2025-03-31\",\n \"documentContentWordsChunked\": [\n {\n \"passage\": \"Scope includes installation of 10 new switches...\",\n \"embedding\": [\n 0,\n 0,\n 0\n ]\n }\n ]\n },\n {\n \"contractId\": \"C-1002\",\n \"title\": \"Cloud Storage Agreement\",\n \"description\": \"Annual cloud storage services for supplier ABC.\",\n \"status\": \"closed\",\n \"priority\": \"medium\",\n \"category\": \"cloud\",\n \"assignee\": \"account manager\",\n \"createdAt\": \"2024-06-05T14:22:10Z\",\n \"price\": 85000,\n \"supplierName\": \"ABC Cloud\",\n \"startDate\": \"2024-07-01\",\n \"endDate\": \"2025-06-30\",\n \"documentContentWordsChunked\": [\n {\n \"passage\": \"The agreement covers 50TB of storage...\",\n \"embedding\": [\n 0,\n 0,\n 0\n ]\n }\n ]\n },\n {\n \"contractId\": \"C-1003\",\n \"title\": \"Enterprise Software License\",\n \"description\": \"License renewal for enterprise software suite.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"software\",\n \"assignee\": \"tech support\",\n \"createdAt\": \"2024-10-01T09:45:00Z\",\n \"price\": 200000,\n \"supplierName\": \"SoftSolutions Ltd.\",\n \"startDate\": \"2025-01-01\",\n \"endDate\": \"2027-12-31\",\n \"documentContentWordsChunked\": [\n {\n \"passage\": \"Renewal includes support and updates for 3 years...\",\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 21 open tickets\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, I can retrieve the requested documents. Please specify any additional filters.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"List 10 recent contracts\",\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: List 21 high-priority network contracts assigned to tech support\n\nRephrased Query: Retrieve the first 21 contracts 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\": 21,\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": "sorted_listing", "size": 21, "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\": \"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\": \"RP-002\",\n \"title\": \"Machine Learning for Healthcare\",\n \"author\": \"Prof. Bob 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 \"AI\"\n ],\n \"confidentialityLevel\": \"internal\"\n },\n {\n \"documentId\": \"RP-003\",\n \"title\": \"Renewable Energy Policy Overview\",\n \"author\": \"Dr. Carol Nguyen\",\n \"department\": \"Environmental Studies\",\n \"createdAt\": \"2022-11-03T11: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\": \"Can you list all approved research papers?\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, I will retrieve the approved documents 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 documents 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 \"knn\": {\n \"documentContentWordsChunked.embedding\": {\n \"vector\": [],\n \"k\": 10\n }\n }\n },\n {\n \"match_all\": {}\n }\n ],\n \"minimum_should_match\": 1\n }\n }\n }\n}" } ]
{ "domain": "Research Papers", "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: 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\": \"User 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 },\n {\n \"ticketId\": \"TCK-1002\",\n \"title\": \"Inventory count discrepancy\",\n \"description\": \"Physical count does not match system records for SKU 12345.\",\n \"status\": \"in_progress\",\n \"priority\": \"medium\",\n \"category\": \"inventory\",\n \"assignee\": \"warehouse_team\",\n \"createdAt\": \"2025-10-18T14:42:10Z\",\n \"price\": 0\n },\n {\n \"ticketId\": \"TCK-1003\",\n \"title\": \"Software license renewal\",\n \"description\": \"Renewal needed for Adobe Creative Cloud licenses.\",\n \"status\": \"resolved\",\n \"priority\": \"low\",\n \"category\": \"software\",\n \"assignee\": \"procurement\",\n \"createdAt\": \"2025-09-30T09:05:45Z\",\n \"price\": 1500\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Show tickets\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Here are the most recent tickets from the inventory system.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"list 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 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": "Inventory Items", "data_type": "structured", "query_type": "listing", "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\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\": \"published\",\n \"category\": \"Research\",\n \"tags\": [\n \"quantum\",\n \"computing\",\n \"technology\"\n ],\n \"confidentialityLevel\": \"public\"\n },\n {\n \"documentId\": \"doc-002\",\n \"title\": \"Machine Learning in Healthcare\",\n \"author\": \"Prof. John Doe\",\n \"department\": \"Computer Science\",\n \"createdAt\": \"2024-01-20T14:15:00Z\",\n \"fileType\": \"docx\",\n \"status\": \"draft\",\n \"category\": \"Review\",\n \"tags\": [\n \"machine learning\",\n \"healthcare\",\n \"AI\"\n ],\n \"confidentialityLevel\": \"internal\"\n },\n {\n \"documentId\": \"doc-003\",\n \"title\": \"Economic Impacts of Climate Change\",\n \"author\": \"Dr. Maria Garcia\",\n \"department\": \"Economics\",\n \"createdAt\": \"2022-11-03T08:00:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"published\",\n \"category\": \"Policy\",\n \"tags\": [\n \"climate change\",\n \"economics\",\n \"policy\"\n ],\n \"confidentialityLevel\": \"public\"\n }\n]\n\nChat History:\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 documents\n\nRephrased Query: List all academic articles\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": "Academic Articles", "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: 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\": \"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 Department Budget Report 2024\",\n \"author\": \"bob.johnson\",\n \"department\": \"Finance\",\n \"createdAt\": \"2024-03-10T14:20:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"draft\",\n \"category\": \"report\",\n \"tags\": [\n \"budget\",\n \"2024\",\n \"finance\"\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: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\": \"Data Privacy Impact Assessment\",\n \"author\": \"david.kim\",\n \"department\": \"Legal\",\n \"createdAt\": \"2024-01-22T11:45:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"assessment\",\n \"tags\": [\n \"privacy\",\n \"data\",\n \"assessment\"\n ],\n \"confidentialityLevel\": \"restricted\"\n },\n {\n \"documentId\": \"doc-005\",\n \"title\": \"Cybersecurity Incident Response Plan\",\n \"author\": \"eva.martinez\",\n \"department\": \"IT Security\",\n \"createdAt\": \"2024-04-01T10:15:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"plan\",\n \"tags\": [\n \"incident\",\n \"response\",\n \"cybersecurity\"\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\": \"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 all draft reports\",\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"term\": {\n \"status\": \"draft\"\n }\n },\n {\n \"term\": {\n \"category\": \"report\"\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 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\": 10,\n \"from\": 10,\n \"query\": {\n \"hybrid\": {\n \"vector\": {\n \"field\": \"documentContentWordsChunked.embedding\",\n \"query_vector\": [\n 0,\n 0,\n 0,\n \"...\"\n ],\n \"k\": 10\n },\n \"text\": {\n \"multi_match\": {\n \"query\": \"approved policies IT Security\",\n \"fields\": [\n \"title^3\",\n \"tags^2\",\n \"category\",\n \"department\"\n ]\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": "Research Papers", "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: 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\": \"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.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\": \"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\nChat History:\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 \"query\": {\n \"bool\": {\n \"filter\": [\n {\n \"term\": {\n \"department\": \"Finance\"\n }\n },\n {\n \"range\": {\n \"createdAt\": {\n \"gte\": \"2024-01-01\"\n }\n }\n },\n {\n \"term\": {\n \"fileType\": \"pdf\"\n }\n }\n ]\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 \"text_embedding\": {\n \"field\": \"documentContentWordsChunked.embedding\",\n \"query_text\": \"approved policies\",\n \"k\": 10\n },\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": "Product Reviews", "data_type": "unstructured", "query_type": "hybrid_search_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\": \"Company Picnic Announcement\",\n \"author\": \"alice.smith\",\n \"department\": \"HR\",\n \"createdAt\": \"2024-03-12T09:15:00Z\",\n \"fileType\": \"text\",\n \"status\": \"published\",\n \"category\": \"event\",\n \"tags\": [\n \"picnic\",\n \"announcement\"\n ],\n \"confidentialityLevel\": \"public\"\n },\n {\n \"documentId\": \"post-002\",\n \"title\": \"Quarterly Security Update\",\n \"author\": \"bob.jones\",\n \"department\": \"IT 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\": \"Remote Work Best Practices\",\n \"author\": \"carla.lee\",\n \"department\": \"HR\",\n \"createdAt\": \"2024-02-20T11:00:00Z\",\n \"fileType\": \"text\",\n \"status\": \"published\",\n \"category\": \"guideline\",\n \"tags\": [\n \"remote\",\n \"work\",\n \"guidelines\"\n ],\n \"confidentialityLevel\": \"public\"\n },\n {\n \"documentId\": \"post-004\",\n \"title\": \"Finance Q3 Report\",\n \"author\": \"david.kim\",\n \"department\": \"Finance\",\n \"createdAt\": \"2024-08-15T08:45:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"draft\",\n \"category\": \"report\",\n \"tags\": [\n \"finance\",\n \"Q3\",\n \"report\"\n ],\n \"confidentialityLevel\": \"confidential\"\n },\n {\n \"documentId\": \"post-005\",\n \"title\": \"New Employee Onboarding Checklist\",\n \"author\": \"emma.wilson\",\n \"department\": \"HR\",\n \"createdAt\": \"2024-01-05T10:20:00Z\",\n \"fileType\": \"text\",\n \"status\": \"approved\",\n \"category\": \"process\",\n \"tags\": [\n \"onboarding\",\n \"checklist\"\n ],\n \"confidentialityLevel\": \"internal\"\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Can you list the latest company announcements?\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, here are the most recent announcements...\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"List recent posts\",\n \"dsl_type\": \"keyword_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 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": "Social Media Posts", "data_type": "unstructured", "query_type": "hybrid_search", "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 \"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\": \"HR-001\",\n \"title\": \"Payroll discrepancy for employee John Doe\",\n \"description\": \"John Doe reported that his last paycheck was $200 short.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"payroll\",\n \"assignee\": \"finance_team\",\n \"createdAt\": \"2025-10-20T09:15:00Z\",\n \"price\": 0\n },\n {\n \"ticketId\": \"HR-002\",\n \"title\": \"Request for vacation leave\",\n \"description\": \"Emily Smith requests vacation from 2025-12-01 to 2025-12-10.\",\n \"status\": \"closed\",\n \"priority\": \"low\",\n \"category\": \"leave\",\n \"assignee\": \"hr_manager\",\n \"createdAt\": \"2025-09-15T14:30:00Z\",\n \"price\": 0\n },\n {\n \"ticketId\": \"HR-003\",\n \"title\": \"Update personal information\",\n \"description\": \"Michael Brown needs to update his address and emergency contact.\",\n \"status\": \"open\",\n \"priority\": \"medium\",\n \"category\": \"profile_update\",\n \"assignee\": \"hr_support\",\n \"createdAt\": \"2025-11-01T08:45: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\": \"Sure, retrieving all open tickets for you.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"List high‑priority payroll tickets assigned to finance_team\",\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 \"priority\": \"high\"\n }\n },\n {\n \"term\": {\n \"category\": \"payroll\"\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 }\n]\n\nUser Query: Show open tickets\n\nRephrased Query: List all open 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_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": "HR Employee Records", "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: HR Employee Records\n\nField Mappings:\n{\n \"properties\": {\n \"employeeId\": {\n \"type\": \"keyword\"\n },\n \"name\": {\n \"type\": \"text\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"department\": {\n \"type\": \"keyword\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"hireDate\": {\n \"type\": \"date\"\n },\n \"salary\": {\n \"type\": \"double\"\n },\n \"location\": {\n \"type\": \"keyword\"\n },\n \"managerId\": {\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 \"employeeId\": \"E001\",\n \"name\": \"Alice Johnson\",\n \"title\": \"Senior Software Engineer\",\n \"department\": \"Engineering\",\n \"status\": \"active\",\n \"hireDate\": \"2018-04-12\",\n \"salary\": 115000,\n \"location\": \"New York\",\n \"managerId\": \"M100\",\n \"documentContentWordsChunked\": [\n {\n \"passage\": \"Alice has led multiple successful product launches.\",\n \"embedding\": [\n 0,\n 0,\n \"...\"\n ]\n }\n ]\n },\n {\n \"employeeId\": \"E002\",\n \"name\": \"Bob Martinez\",\n \"title\": \"HR Business Partner\",\n \"department\": \"Human Resources\",\n \"status\": \"active\",\n \"hireDate\": \"2020-09-01\",\n \"salary\": 85000,\n \"location\": \"San Francisco\",\n \"managerId\": \"M200\",\n \"documentContentWordsChunked\": [\n {\n \"passage\": \"Bob specializes in talent acquisition and employee relations.\",\n \"embedding\": [\n 0,\n 0,\n \"...\"\n ]\n }\n ]\n },\n {\n \"employeeId\": \"E003\",\n \"name\": \"Carol Singh\",\n \"title\": \"Finance Analyst\",\n \"department\": \"Finance\",\n \"status\": \"on_leave\",\n \"hireDate\": \"2019-02-20\",\n \"salary\": 72000,\n \"location\": \"Chicago\",\n \"managerId\": \"M300\",\n \"documentContentWordsChunked\": [\n {\n \"passage\": \"Carol handles quarterly budgeting and forecasting.\",\n \"embedding\": [\n 0,\n 0,\n \"...\"\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\": \"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 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 \"hireDate\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n}" } ]
{ "domain": "HR Employee Records", "data_type": "structured", "query_type": "listing", "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\": \"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 \"compliance\"\n ],\n \"confidentialityLevel\": \"high\"\n },\n {\n \"documentId\": \"MR-002\",\n \"title\": \"Patient Data Retention Guidelines\",\n \"author\": \"bob.johnson\",\n \"department\": \"Medical Records\",\n \"createdAt\": \"2023-11-01T14:12:00Z\",\n \"fileType\": \"docx\",\n \"status\": \"draft\",\n \"category\": \"guideline\",\n \"tags\": [\n \"retention\",\n \"privacy\"\n ],\n \"confidentialityLevel\": \"medium\"\n },\n {\n \"documentId\": \"MR-003\",\n \"title\": \"Finance Department Quarterly Report Q1 2024\",\n \"author\": \"carol.williams\",\n \"department\": \"Finance\",\n \"createdAt\": \"2024-04-10T08:00:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"report\",\n \"tags\": [\n \"quarterly\",\n \"financial\"\n ],\n \"confidentialityLevel\": \"high\"\n },\n {\n \"documentId\": \"MR-004\",\n \"title\": \"Remote Work Security Checklist\",\n \"author\": \"david.lee\",\n \"department\": \"IT Security\",\n \"createdAt\": \"2024-06-05T11:45:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"checklist\",\n \"tags\": [\n \"remote\",\n \"security\",\n \"vpn\"\n ],\n \"confidentialityLevel\": \"low\"\n },\n {\n \"documentId\": \"MR-005\",\n \"title\": \"Clinical Trial Protocol – Phase II\",\n \"author\": \"emma.brown\",\n \"department\": \"Research\",\n \"createdAt\": \"2023-09-20T16:20:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"protocol\",\n \"tags\": [\n \"clinical\",\n \"trial\",\n \"phase2\"\n ],\n \"confidentialityLevel\": \"high\"\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 policies from the IT Security department.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"List 10 recent documents from Finance\",\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 19 approved policies from IT Security department as PDFs\n\nRephrased Query: Retrieve 19 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\": 19,\n \"from\": 0,\n \"query\": {\n \"hybrid\": {\n \"text\": {\n \"query\": \"security policy\",\n \"fields\": [\n \"title\",\n \"tags\"\n ]\n },\n \"vector\": {\n \"field\": \"documentContentWordsChunked.embedding\",\n \"query_vector\": [\n 0,\n 0,\n \"...\"\n ],\n \"k\": 19\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": "Medical Records", "data_type": "unstructured", "query_type": "hybrid_search_with_filters", "pattern": "initial", "pattern_type": "sorted_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: Product Catalog 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 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\": \"TCKT-002\",\n \"title\": \"Software license renewal\",\n \"description\": \"Renewal of Adobe Creative Cloud licenses for design team.\",\n \"status\": \"resolved\",\n \"priority\": \"medium\",\n \"category\": \"software\",\n \"assignee\": \"procurement\",\n \"createdAt\": \"2025-09-12T14:42:10Z\",\n \"price\": 1200\n },\n {\n \"ticketId\": \"TCKT-003\",\n \"title\": \"Printer malfunction\",\n \"description\": \"Office printer prints blank pages intermittently.\",\n \"status\": \"in_progress\",\n \"priority\": \"low\",\n \"category\": \"hardware\",\n \"assignee\": \"facility team\",\n \"createdAt\": \"2025-11-01T09:05:45Z\",\n \"price\": 250.75\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Can you give me a summary of recent tickets?\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, here is a brief overview of tickets created in the last week...\"\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 \"_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 assigned to tech support with high priority\n\nRephrased Query: List tickets where status is open, priority is high, 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 \"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": "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 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\": \"Excellent Battery Life Review\",\n \"author\": \"alice.smith\",\n \"department\": \"Electronics\",\n \"createdAt\": \"2024-03-12T09:15:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"Smartphones\",\n \"tags\": [\n \"battery\",\n \"performance\"\n ],\n \"confidentialityLevel\": \"public\"\n },\n {\n \"documentId\": \"PR-002\",\n \"title\": \"Comfortable Ergonomic Chair Feedback\",\n \"author\": \"bob.jones\",\n \"department\": \"Furniture\",\n \"createdAt\": \"2024-05-08T14:30:00Z\",\n \"fileType\": \"docx\",\n \"status\": \"approved\",\n \"category\": \"Office Furniture\",\n \"tags\": [\n \"ergonomic\",\n \"comfort\"\n ],\n \"confidentialityLevel\": \"public\"\n },\n {\n \"documentId\": \"PR-003\",\n \"title\": \"High-Resolution Camera Test\",\n \"author\": \"carla.lee\",\n \"department\": \"Electronics\",\n \"createdAt\": \"2024-01-22T11:45:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"Cameras\",\n \"tags\": [\n \"resolution\",\n \"lowlight\"\n ],\n \"confidentialityLevel\": \"public\"\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Can you give me the latest approved product reviews?\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, here are the most recent approved reviews across all departments.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"Show 10 recent approved reviews\",\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 46 approved product reviews from the Electronics department\n\nRephrased Query: Retrieve 46 approved product reviews in 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\": \"hybrid_search\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 46,\n \"from\": 0,\n \"query\": {\n \"bool\": {\n \"should\": [\n {\n \"match\": {\n \"title\": {\n \"query\": \"approved product reviews electronics\",\n \"operator\": \"and\"\n }\n }\n },\n {\n \"knn\": {\n \"documentContentWordsChunked.embedding\": {\n \"vector\": [],\n \"k\": 46\n }\n }\n }\n ],\n \"minimum_should_match\": 1\n }\n }\n }\n}" } ]
{ "domain": "Product Reviews", "data_type": "unstructured", "query_type": "hybrid_search", "pattern": "refinement", "pattern_type": "change_sort", "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: Customer Profiles\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\": \"Unable to access account\",\n \"description\": \"Customer reports that they cannot log into their account after password reset.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"account\",\n \"assignee\": \"tech_support_1\",\n \"createdAt\": \"2025-10-20T08:15:30Z\",\n \"price\": 0\n },\n {\n \"ticketId\": \"TCK-1002\",\n \"title\": \"Billing discrepancy\",\n \"description\": \"Invoice shows an extra charge for premium support that was not requested.\",\n \"status\": \"open\",\n \"priority\": \"medium\",\n \"category\": \"billing\",\n \"assignee\": \"finance_team\",\n \"createdAt\": \"2025-10-19T14:42:10Z\",\n \"price\": 120.5\n },\n {\n \"ticketId\": \"TCK-1003\",\n \"title\": \"Feature request: Dark mode\",\n \"description\": \"Customer would like 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:45Z\",\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 retrieve the tickets. Do you have any specific filters or a number of results in mind?\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"Show 10 recent 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 me 19 tickets\n\nRephrased Query: list 19 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\": 19,\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": "keyword_search", "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: 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 \"documentContentWords\": {\n \"type\": \"text\"\n }\n }\n}\n\nSample Documents:\n[\n {\n \"ticketId\": \"TCK-001\",\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:00Z\",\n \"price\": 0,\n \"documentContentWordsChunked\": [\n {\n \"passage\": \"Investigate VPN gateway logs for packet loss.\",\n \"embedding\": [\n 0,\n 0,\n \"...\"\n ]\n }\n ]\n },\n {\n \"ticketId\": \"TCK-002\",\n \"title\": \"Database backup failure\",\n \"description\": \"Nightly backup of the finance DB failed due to storage quota.\",\n \"status\": \"in_progress\",\n \"priority\": \"medium\",\n \"category\": \"database\",\n \"assignee\": \"db admin\",\n \"createdAt\": \"2025-10-18T22:30:00Z\",\n \"price\": 0,\n \"documentContentWordsChunked\": [\n {\n \"passage\": \"Check storage allocation and increase quota.\",\n \"embedding\": [\n 0,\n 0,\n \"...\"\n ]\n }\n ]\n },\n {\n \"ticketId\": \"TCK-003\",\n \"title\": \"UI redesign for dashboard\",\n \"description\": \"Create a new responsive layout for the analytics dashboard.\",\n \"status\": \"closed\",\n \"priority\": \"low\",\n \"category\": \"ui\",\n \"assignee\": \"design team\",\n \"createdAt\": \"2025-09-30T14:45:00Z\",\n \"price\": 1500,\n \"documentContentWordsChunked\": [\n {\n \"passage\": \"Use the new component library for consistency.\",\n \"embedding\": [\n 0,\n 0,\n \"...\"\n ]\n }\n ]\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Show high-priority network tickets assigned to tech support\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, retrieving high‑priority network tickets that are currently assigned to the tech support team.\"\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 \"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 \"_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 high-priority network tickets assigned to tech support\n\nRephrased Query: Retrieve 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\": 20,\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": "Project Management Tasks", "data_type": "structured", "query_type": "listing_with_filters", "pattern": "pagination", "pattern_type": "specific_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: 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-00123\",\n \"title\": \"Password Reset Request\",\n \"author\": \"jdoe\",\n \"department\": \"IT\",\n \"createdAt\": \"2024-09-12T08:15:30Z\",\n \"fileType\": \"pdf\",\n \"status\": \"open\",\n \"category\": \"authentication\",\n \"tags\": [\n \"password\",\n \"reset\",\n \"urgent\"\n ],\n \"confidentialityLevel\": \"internal\"\n },\n {\n \"documentId\": \"TCKT-00456\",\n \"title\": \"Expense Reimbursement Approval\",\n \"author\": \"asmith\",\n \"department\": \"Finance\",\n \"createdAt\": \"2024-08-20T14:42:10Z\",\n \"fileType\": \"docx\",\n \"status\": \"approved\",\n \"category\": \"finance\",\n \"tags\": [\n \"expense\",\n \"reimbursement\"\n ],\n \"confidentialityLevel\": \"confidential\"\n },\n {\n \"documentId\": \"TCKT-00789\",\n \"title\": \"Remote Work Policy Update\",\n \"author\": \"mbrown\",\n \"department\": \"HR\",\n \"createdAt\": \"2024-07-05T10:00: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\": \"TCKT-00901\",\n \"title\": \"Server Outage Incident Report\",\n \"author\": \"lwilson\",\n \"department\": \"IT\",\n \"createdAt\": \"2024-09-01T22:30:45Z\",\n \"fileType\": \"pdf\",\n \"status\": \"closed\",\n \"category\": \"incident\",\n \"tags\": [\n \"server\",\n \"outage\",\n \"report\"\n ],\n \"confidentialityLevel\": \"internal\"\n },\n {\n \"documentId\": \"TCKT-01012\",\n \"title\": \"Annual Security Audit Findings\",\n \"author\": \"klee\",\n \"department\": \"IT Security\",\n \"createdAt\": \"2024-06-15T09:20:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"security\",\n \"tags\": [\n \"audit\",\n \"security\",\n \"findings\"\n ],\n \"confidentialityLevel\": \"confidential\"\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Can you show me the latest tickets from the IT department?\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, here are the most recent IT tickets:\\n1. TCKT-00123 – Password Reset Request (open)\\n2. TCKT-00901 – Server Outage Incident Report (closed)\\nWould you like to apply any filters or see more?\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"List 10 open tickets from Finance\",\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"term\": {\n \"status\": \"open\"\n }\n },\n {\n \"term\": {\n \"department\": \"Finance\"\n }\n }\n ]\n }\n },\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n }\n }\n }\n]\n\nUser Query: List $20 approved tickets from IT Security department\n\nRephrased Query: Retrieve the first 20 tickets that have status approved and belong 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\": 20,\n \"from\": 0,\n \"query\": {\n \"hybrid\": {\n \"query\": \"approved tickets\",\n \"embedding\": {\n \"vector\": [],\n \"k\": 20\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": "keyword_search", "size": 20, "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\": \"HR-001\",\n \"title\": \"Onboarding paperwork missing\",\n \"description\": \"New hire John Doe has not submitted required onboarding documents.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"onboarding\",\n \"assignee\": \"HR Manager\",\n \"createdAt\": \"2025-10-20T09:15:00Z\",\n \"price\": 0,\n \"documentContentWordsChunked\": [\n {\n \"passage\": \"New hire John Doe has not submitted required onboarding documents.\",\n \"embedding\": [\n 0,\n 0,\n \"...\"\n ]\n }\n ]\n },\n {\n \"ticketId\": \"HR-002\",\n \"title\": \"Salary discrepancy for employee\",\n \"description\": \"Employee Jane Smith reports a discrepancy in her monthly salary.\",\n \"status\": \"in_progress\",\n \"priority\": \"medium\",\n \"category\": \"payroll\",\n \"assignee\": \"Payroll Specialist\",\n \"createdAt\": \"2025-10-18T14:30:00Z\",\n \"price\": 0,\n \"documentContentWordsChunked\": [\n {\n \"passage\": \"Employee Jane Smith reports a discrepancy in her monthly salary.\",\n \"embedding\": [\n 0,\n 0,\n \"...\"\n ]\n }\n ]\n },\n {\n \"ticketId\": \"HR-003\",\n \"title\": \"Request for vacation approval\",\n \"description\": \"Mark Lee requests vacation from 2025-12-01 to 2025-12-10.\",\n \"status\": \"resolved\",\n \"priority\": \"low\",\n \"category\": \"leave\",\n \"assignee\": \"HR Coordinator\",\n \"createdAt\": \"2025-09-25T11:45:00Z\",\n \"price\": 0,\n \"documentContentWordsChunked\": [\n {\n \"passage\": \"Mark Lee requests vacation from 2025-12-01 to 2025-12-10.\",\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 assigned to HR manager\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, retrieving open tickets where the assignee is HR manager.\"\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 \"_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 assigned to HR manager\n\nRephrased Query: Retrieve open tickets where assignee is HR manager\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\": \"HR Manager\"\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: HR Employee Records\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\": \"HR-001\",\n \"title\": \"Onboarding Checklist for New Hire\",\n \"description\": \"Complete onboarding tasks for John Doe, Software Engineer.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"onboarding\",\n \"assignee\": \"hr_team\",\n \"createdAt\": \"2024-09-01T08:30:00Z\",\n \"price\": 0,\n \"documentContentWordsChunked\": [\n {\n \"passage\": \"Welcome to the company...\",\n \"embedding\": [\n 0,\n 0,\n 0\n ]\n }\n ]\n },\n {\n \"documentId\": \"HR-002\",\n \"title\": \"Annual Performance Review - Jane Smith\",\n \"description\": \"Performance review document for Jane Smith, Marketing Manager.\",\n \"status\": \"closed\",\n \"priority\": \"medium\",\n \"category\": \"performance\",\n \"assignee\": \"manager_marketing\",\n \"createdAt\": \"2024-03-15T14:20:00Z\",\n \"price\": 0,\n \"documentContentWordsChunked\": [\n {\n \"passage\": \"Jane has consistently exceeded targets...\",\n \"embedding\": [\n 0,\n 0,\n 0\n ]\n }\n ]\n },\n {\n \"documentId\": \"HR-003\",\n \"title\": \"Salary Adjustment Request\",\n \"description\": \"Request to adjust salary for Michael Lee, Senior Analyst.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"compensation\",\n \"assignee\": \"finance_team\",\n \"createdAt\": \"2024-10-05T11:45:00Z\",\n \"price\": 0,\n \"documentContentWordsChunked\": [\n {\n \"passage\": \"Based on market benchmarks...\",\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 the open HR 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 10 recent HR documents\",\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: Please list 90 high‑priority open HR tickets assigned to hr_team\n\nRephrased Query: Retrieve 90 documents where status is open, priority is high, and assignee is hr_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\": 90,\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\": \"hr_team\"\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": "filtered_search", "size": 90, "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-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\": \"Data Encryption Guidelines\",\n \"author\": \"bob.johnson\",\n \"department\": \"IT Security\",\n \"createdAt\": \"2024-06-01T14:12:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"policy\",\n \"tags\": [\n \"encryption\",\n \"data\",\n \"guidelines\"\n ],\n \"confidentialityLevel\": \"confidential\"\n },\n {\n \"documentId\": \"doc-003\",\n \"title\": \"Incident Response Procedure\",\n \"author\": \"carol.lee\",\n \"department\": \"IT Security\",\n \"createdAt\": \"2024-01-20T08:45:00Z\",\n \"fileType\": \"docx\",\n \"status\": \"draft\",\n \"category\": \"procedure\",\n \"tags\": [\n \"incident\",\n \"response\",\n \"procedure\"\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 policies from the IT Security department.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"Show me 10 recent documents\",\n \"dsl_type\": \"simple_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 47 approved policies from IT Security\n\nRephrased Query: Retrieve 47 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\": \"listing_with_filters\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 47,\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 \"term\": {\n \"fileType\": \"pdf\"\n }\n }\n ]\n }\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n}" } ]
{ "domain": "Corporate Blog Posts", "data_type": "unstructured", "query_type": "listing_with_filters", "pattern": "initial", "pattern_type": "complex_query", "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: 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 appears down.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"network\",\n \"assignee\": \"john.doe\",\n \"createdAt\": \"2025-10-20T08:15:00Z\",\n \"price\": 0\n },\n {\n \"ticketId\": \"TCK-1002\",\n \"title\": \"Email sync error\",\n \"description\": \"Outlook fails to sync new emails for several users.\",\n \"status\": \"resolved\",\n \"priority\": \"medium\",\n \"category\": \"software\",\n \"assignee\": \"jane.smith\",\n \"createdAt\": \"2025-09-15T14:30:00Z\",\n \"price\": 0\n },\n {\n \"ticketId\": \"TCK-1003\",\n \"title\": \"Printer jam in Finance department\",\n \"description\": \"Laser printer on 2nd floor shows paper jam error.\",\n \"status\": \"in_progress\",\n \"priority\": \"low\",\n \"category\": \"hardware\",\n \"assignee\": \"mike.lee\",\n \"createdAt\": \"2025-11-01T09:45:00Z\",\n \"price\": 0\n },\n {\n \"ticketId\": \"TCK-1004\",\n \"title\": \"VPN access denied\",\n \"description\": \"Remote employee cannot connect to corporate VPN.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"network\",\n \"assignee\": \"john.doe\",\n \"createdAt\": \"2025-11-10T11:20:00Z\",\n \"price\": 0\n },\n {\n \"ticketId\": \"TCK-1005\",\n \"title\": \"Software license renewal\",\n \"description\": \"Need to renew Adobe Creative Cloud licenses for design team.\",\n \"status\": \"closed\",\n \"priority\": \"low\",\n \"category\": \"software\",\n \"assignee\": \"sarah.kim\",\n \"createdAt\": \"2025-08-05T16:00:00Z\",\n \"price\": 1200\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 \"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 \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n }\n }\n }\n]\n\nUser Query: Show high priority network tickets assigned to John\n\nRephrased Query: List open tickets where status is open, priority is high, category is network, and assignee is 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 \"category\": \"network\"\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": "IT Support Tickets", "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: 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-03-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\": \"post-002\",\n \"title\": \"Remote Work Guidelines\",\n \"author\": \"bob.jones\",\n \"department\": \"HR\",\n \"createdAt\": \"2024-01-10T14:45: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\": \"carol.lee\",\n \"department\": \"Finance\",\n \"createdAt\": \"2024-02-28T11:20: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\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Show tickets\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Here are the most recent tickets from the system.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"list documents\",\n \"dsl_type\": \"keyword_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 the latest 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 \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"should\": [\n {\n \"knn\": {\n \"field\": \"documentContentWordsChunked.embedding\",\n \"query_vector\": [\n 0.1,\n 0.2,\n 0.3\n ],\n \"k\": 10,\n \"num_candidates\": 100\n }\n }\n ]\n }\n }\n }\n}" } ]
{ "domain": "Social Media Posts", "data_type": "unstructured", "query_type": "hybrid_search", "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: 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 Smith\",\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 Lee\",\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\nPrevious DSL History:\n[\n {\n \"user_query\": \"list all documents\",\n \"dsl_type\": \"match_all\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"query\": {\n \"match_all\": {}\n }\n }\n }\n]\n\nUser Query: Show documents\n\nRephrased Query: retrieve a list of documents 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_all\": {}\n },\n {\n \"knn\": {\n \"documentContentWordsChunked.embedding\": {\n \"vector\": [\n 0,\n 0,\n \"...\"\n ],\n \"k\": 10\n }\n }\n }\n ],\n \"minimum_should_match\": 1\n }\n }\n }\n}" } ]
{ "domain": "Technical Manuals", "data_type": "unstructured", "query_type": "hybrid_search", "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 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\": \"Q3 Financial Review\",\n \"author\": \"alice.smith\",\n \"department\": \"Finance\",\n \"createdAt\": \"2024-07-15T09:30:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"Report\",\n \"tags\": [\n \"quarterly\",\n \"revenue\",\n \"expenses\"\n ],\n \"confidentialityLevel\": \"internal\"\n },\n {\n \"documentId\": \"doc-002\",\n \"title\": \"Employee Satisfaction Survey Results\",\n \"author\": \"bob.johnson\",\n \"department\": \"HR\",\n \"createdAt\": \"2023-12-01T14:20:00Z\",\n \"fileType\": \"docx\",\n \"status\": \"draft\",\n \"category\": \"Survey\",\n \"tags\": [\n \"engagement\",\n \"feedback\"\n ],\n \"confidentialityLevel\": \"restricted\"\n },\n {\n \"documentId\": \"doc-003\",\n \"title\": \"IT Security Policy Update\",\n \"author\": \"carol.lee\",\n \"department\": \"IT Security\",\n \"createdAt\": \"2024-02-10T11:00:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"Policy\",\n \"tags\": [\n \"security\",\n \"compliance\"\n ],\n \"confidentialityLevel\": \"public\"\n },\n {\n \"documentId\": \"doc-004\",\n \"title\": \"Marketing Campaign Performance\",\n \"author\": \"dave.kumar\",\n \"department\": \"Marketing\",\n \"createdAt\": \"2024-05-22T08:45:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"Report\",\n \"tags\": [\n \"campaign\",\n \"ROI\"\n ],\n \"confidentialityLevel\": \"internal\"\n },\n {\n \"documentId\": \"doc-005\",\n \"title\": \"Remote Work Guidelines\",\n \"author\": \"eve.wang\",\n \"department\": \"HR\",\n \"createdAt\": \"2024-01-05T10:15:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"Policy\",\n \"tags\": [\n \"remote\",\n \"guidelines\"\n ],\n \"confidentialityLevel\": \"public\"\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Can you show me the latest finance reports?\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, here are the most recent finance reports sorted by date.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"Show me 10 recent 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 }\n }\n]\n\nUser Query: $List $24 PDFs from Finance department after 2024\n\nRephrased Query: List 24 approved PDF documents in the Finance department with a creation date 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\": 24,\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 \"term\": {\n \"status\": \"approved\"\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": 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: HR Employee Records\n\nField Mappings:\n{\n \"properties\": {\n \"employeeId\": {\n \"type\": \"keyword\"\n },\n \"name\": {\n \"type\": \"text\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"department\": {\n \"type\": \"keyword\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"hireDate\": {\n \"type\": \"date\"\n },\n \"salary\": {\n \"type\": \"double\"\n },\n \"location\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\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 \"employeeId\": \"E001\",\n \"name\": \"Alice Johnson\",\n \"title\": \"Senior Software Engineer\",\n \"department\": \"Engineering\",\n \"status\": \"Active\",\n \"hireDate\": \"2018-04-12\",\n \"salary\": 115000,\n \"location\": \"New York\",\n \"createdAt\": \"2024-10-01T08:15:30Z\"\n },\n {\n \"employeeId\": \"E002\",\n \"name\": \"Bob Martinez\",\n \"title\": \"HR Manager\",\n \"department\": \"Human Resources\",\n \"status\": \"Active\",\n \"hireDate\": \"2016-09-23\",\n \"salary\": 95000,\n \"location\": \"San Francisco\",\n \"createdAt\": \"2024-09-28T14:42:10Z\"\n },\n {\n \"employeeId\": \"E003\",\n \"name\": \"Carol Lee\",\n \"title\": \"Finance Analyst\",\n \"department\": \"Finance\",\n \"status\": \"On Leave\",\n \"hireDate\": \"2020-01-15\",\n \"salary\": 72000,\n \"location\": \"Chicago\",\n \"createdAt\": \"2024-09-30T11:07:55Z\"\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 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": "HR Employee Records", "data_type": "structured", "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: 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-12T08: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 \"prediction\"\n ],\n \"confidentialityLevel\": \"internal\"\n },\n {\n \"documentId\": \"RP-003\",\n \"title\": \"Cybersecurity Policies 2024\",\n \"author\": \"Catherine Patel\",\n \"department\": \"IT Security\",\n \"createdAt\": \"2024-03-05T10:00:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"policy\",\n \"tags\": [\n \"security\",\n \"policy\",\n \"remote work\"\n ],\n \"confidentialityLevel\": \"confidential\"\n }\n]\n\nChat History:\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 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 \"bool\": {\n \"should\": [\n {\n \"match_all\": {}\n },\n {\n \"knn\": {\n \"field\": \"documentContentWordsChunked.embedding\",\n \"query_vector\": [\n 0,\n 0,\n 0,\n \"...\"\n ],\n \"k\": 10,\n \"num_candidates\": 100\n }\n }\n ],\n \"minimum_should_match\": 1,\n \"filter\": [\n {\n \"term\": {\n \"status\": \"approved\"\n }\n },\n {\n \"term\": {\n \"category\": \"policy\"\n }\n }\n ]\n }\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: 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\": \"Users experience high latency on VPN connections.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"network\",\n \"assignee\": \"tech_support\",\n \"createdAt\": \"2024-10-01T08:15:30Z\",\n \"price\": 0\n },\n {\n \"ticketId\": \"TCK-002\",\n \"title\": \"Database backup failure\",\n \"description\": \"Nightly backup did not complete due to storage quota.\",\n \"status\": \"in_progress\",\n \"priority\": \"medium\",\n \"category\": \"database\",\n \"assignee\": \"db_admin\",\n \"createdAt\": \"2024-09-28T22:00:00Z\",\n \"price\": 0\n },\n {\n \"ticketId\": \"TCK-003\",\n \"title\": \"UI redesign request\",\n \"description\": \"Update dashboard UI to match new branding guidelines.\",\n \"status\": \"closed\",\n \"priority\": \"low\",\n \"category\": \"design\",\n \"assignee\": \"ui_team\",\n \"createdAt\": \"2024-08-15T14:45:10Z\",\n \"price\": 1500\n },\n {\n \"ticketId\": \"TCK-004\",\n \"title\": \"Server patch rollout\",\n \"description\": \"Apply security patches to all production servers.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"infrastructure\",\n \"assignee\": \"ops_team\",\n \"createdAt\": \"2024-10-03T09:30:00Z\",\n \"price\": 0\n },\n {\n \"ticketId\": \"TCK-005\",\n \"title\": \"API rate limit adjustment\",\n \"description\": \"Increase rate limits for partner integrations.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"network\",\n \"assignee\": \"tech_support\",\n \"createdAt\": \"2024-10-02T11:20:45Z\",\n \"price\": 0\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Show me 46 open tickets\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, I will retrieve the first 46 tickets that are currently open.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"List 10 recent 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: List 46 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\": 46,\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": "pagination", "pattern_type": "specific_page", "size": 46, "from": 46, "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: 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-05-12T09:30:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"policy\",\n \"tags\": [\n \"security\",\n \"policy\",\n \"access\"\n ],\n \"confidentialityLevel\": \"confidential\",\n \"documentContentWordsChunked\": []\n },\n {\n \"documentId\": \"DOC-002\",\n \"title\": \"Remote Work Guidelines\",\n \"author\": \"Bob Smith\",\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\": \"internal\",\n \"documentContentWordsChunked\": []\n },\n {\n \"documentId\": \"DOC-003\",\n \"title\": \"Finance Department Annual Report 2024\",\n \"author\": \"Carol Lee\",\n \"department\": \"Finance\",\n \"createdAt\": \"2024-03-10T11:00:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"report\",\n \"tags\": [\n \"finance\",\n \"annual\",\n \"2024\"\n ],\n \"confidentialityLevel\": \"restricted\",\n \"documentContentWordsChunked\": []\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\": \"List all legal 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 a list of tickets without specifying a count\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\": 40,\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"should\": [\n {\n \"knn\": {\n \"documentContentWordsChunked.embedding\": {\n \"vector\": [\n 0,\n 0,\n 0\n ],\n \"k\": 10\n }\n }\n }\n ]\n }\n }\n }\n}" } ]
{ "domain": "Legal Documents", "data_type": "unstructured", "query_type": "hybrid_search", "pattern": "pagination", "pattern_type": "specific_page", "size": 10, "from": 40, "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: HR Employee Records\n\nField Mappings:\n{\n \"properties\": {\n \"employeeId\": {\n \"type\": \"keyword\"\n },\n \"name\": {\n \"type\": \"text\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"department\": {\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 \"salary\": {\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 \"employeeId\": \"E001\",\n \"name\": \"Alice Johnson\",\n \"title\": \"Senior Software Engineer\",\n \"department\": \"Engineering\",\n \"status\": \"active\",\n \"priority\": \"high\",\n \"category\": \"Full-Time\",\n \"assignee\": \"HR_Team_A\",\n \"createdAt\": \"2021-03-15T09:12:00Z\",\n \"salary\": 115000,\n \"documentContentWordsChunked\": [\n {\n \"passage\": \"Alice has led multiple critical projects...\",\n \"embedding\": [\n 0,\n 0,\n \"...\"\n ]\n }\n ]\n },\n {\n \"employeeId\": \"E002\",\n \"name\": \"Bob Martinez\",\n \"title\": \"Data Analyst\",\n \"department\": \"Analytics\",\n \"status\": \"active\",\n \"priority\": \"medium\",\n \"category\": \"Full-Time\",\n \"assignee\": \"HR_Team_B\",\n \"createdAt\": \"2019-07-22T14:45:00Z\",\n \"salary\": 85000,\n \"documentContentWordsChunked\": [\n {\n \"passage\": \"Bob specializes in data visualization...\",\n \"embedding\": [\n 0,\n 0,\n \"...\"\n ]\n }\n ]\n },\n {\n \"employeeId\": \"E003\",\n \"name\": \"Carol Singh\",\n \"title\": \"HR Manager\",\n \"department\": \"Human Resources\",\n \"status\": \"inactive\",\n \"priority\": \"low\",\n \"category\": \"Contract\",\n \"assignee\": \"HR_Team_A\",\n \"createdAt\": \"2018-11-05T08:30:00Z\",\n \"salary\": 95000,\n \"documentContentWordsChunked\": [\n {\n \"passage\": \"Carol oversees recruitment processes...\",\n \"embedding\": [\n 0,\n 0,\n \"...\"\n ]\n }\n ]\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Show me the first 10 employee records.\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Here are the first 10 employee records...\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"Show 10 employee records\",\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: List 15 active high-priority Engineering employees hired after 2020-01-01\n\nRephrased Query: Retrieve 15 employee records where status is active, priority is high, department is Engineering, and createdAt is on or after 2020-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\": 45,\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": [\n {\n \"term\": {\n \"status\": \"active\"\n }\n },\n {\n \"term\": {\n \"priority\": \"high\"\n }\n },\n {\n \"term\": {\n \"department\": \"Engineering\"\n }\n },\n {\n \"range\": {\n \"createdAt\": {\n \"gte\": \"2020-01-01\"\n }\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": 15, "from": 45, "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: 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 Zero Trust Security\",\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 \"zero-trust\",\n \"network\",\n \"policy\"\n ],\n \"confidentialityLevel\": \"public\"\n },\n {\n \"documentId\": \"doc-002\",\n \"title\": \"Remote Work Best Practices\",\n \"author\": \"bob.johnson\",\n \"department\": \"Human Resources\",\n \"createdAt\": \"2023-11-01T14:12:00Z\",\n \"fileType\": \"docx\",\n \"status\": \"draft\",\n \"category\": \"policy\",\n \"tags\": [\n \"remote\",\n \"productivity\",\n \"guidelines\"\n ],\n \"confidentialityLevel\": \"internal\"\n },\n {\n \"documentId\": \"doc-003\",\n \"title\": \"Quarterly Financial Overview Q3 2024\",\n \"author\": \"carla.lee\",\n \"department\": \"Finance\",\n \"createdAt\": \"2024-10-05T08:00:00Z\",\n \"fileType\": \"xlsx\",\n \"status\": \"approved\",\n \"category\": \"finance\",\n \"tags\": [\n \"quarterly\",\n \"report\",\n \"2024\"\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 policy documents...\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"List all approved policies\",\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 a list of documents 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\": \"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\": \"or\"\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"avg\",\n \"query\": {\n \"knn\": {\n \"documentContentWordsChunked.embedding\": {\n \"vector\": [\n 0,\n 0,\n 0,\n \"...\"\n ],\n \"k\": 10\n }\n }\n }\n }\n }\n ],\n \"minimum_should_match\": 1\n }\n }\n }\n}" } ]
{ "domain": "BlogPosts", "data_type": "unstructured", "query_type": "hybrid_search", "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: 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\": \"Global Economic Outlook 2025\",\n \"author\": \"Jane Smith\",\n \"department\": \"Finance\",\n \"createdAt\": \"2024-11-01T08:30:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"published\",\n \"category\": \"Economy\",\n \"tags\": [\n \"economy\",\n \"forecast\",\n \"2025\"\n ],\n \"confidentialityLevel\": \"public\"\n },\n {\n \"documentId\": \"doc-002\",\n \"title\": \"Tech Innovations in AI\",\n \"author\": \"Alan Zhou\",\n \"department\": \"Technology\",\n \"createdAt\": \"2024-10-15T14:12:00Z\",\n \"fileType\": \"docx\",\n \"status\": \"draft\",\n \"category\": \"Technology\",\n \"tags\": [\n \"AI\",\n \"innovation\",\n \"research\"\n ],\n \"confidentialityLevel\": \"internal\"\n },\n {\n \"documentId\": \"doc-003\",\n \"title\": \"Health Guidelines for Remote Workers\",\n \"author\": \"Maria Garcia\",\n \"department\": \"HR\",\n \"createdAt\": \"2024-09-20T09:45:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"published\",\n \"category\": \"Health\",\n \"tags\": [\n \"remote work\",\n \"health\",\n \"guidelines\"\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\": \"Sure, retrieving the latest tickets for you.\"\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 the most 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": "News Articles", "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 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 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 \"documentContentWordsChunked\": []\n },\n {\n \"ticketId\": \"TCKT-002\",\n \"title\": \"Software installation request\",\n \"description\": \"Install Adobe Photoshop on workstation 12.\",\n \"status\": \"resolved\",\n \"priority\": \"medium\",\n \"category\": \"software\",\n \"assignee\": \"app_admin\",\n \"createdAt\": \"2025-09-15T14:30:00Z\",\n \"price\": 0,\n \"documentContentWordsChunked\": []\n },\n {\n \"ticketId\": \"TCKT-003\",\n \"title\": \"Printer jam in Finance department\",\n \"description\": \"HP LaserJet 4200 jammed, needs clearing and toner replacement.\",\n \"status\": \"in_progress\",\n \"priority\": \"low\",\n \"category\": \"hardware\",\n \"assignee\": \"hardware_team\",\n \"createdAt\": \"2025-11-01T09:45:00Z\",\n \"price\": 0,\n \"documentContentWordsChunked\": []\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\": \"Here is the DSL query that will retrieve those tickets.\"\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 \"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 }\n]\n\nUser Query: Show open tickets\n\nRephrased Query: Retrieve all tickets with status 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": "IT Support Tickets", "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: 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 the data center is down, causing network outages.\",\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 corporate laptop.\",\n \"status\": \"closed\",\n \"priority\": \"medium\",\n \"category\": \"hardware\",\n \"assignee\": \"field technician\",\n \"createdAt\": \"2025-09-12T14:42:00Z\",\n \"price\": 120.5,\n \"documentContentWordsChunked\": []\n },\n {\n \"ticketId\": \"TCK-1003\",\n \"title\": \"Software license renewal\",\n \"description\": \"Renewal of Adobe Creative Cloud licenses for design team.\",\n \"status\": \"open\",\n \"priority\": \"low\",\n \"category\": \"software\",\n \"assignee\": \"procurement\",\n \"createdAt\": \"2025-11-01T09:00:00Z\",\n \"price\": 3500,\n \"documentContentWordsChunked\": []\n },\n {\n \"ticketId\": \"TCK-1004\",\n \"title\": \"Server storage upgrade\",\n \"description\": \"Add 2TB SSD to production server for increased capacity.\",\n \"status\": \"in_progress\",\n \"priority\": \"high\",\n \"category\": \"hardware\",\n \"assignee\": \"sysadmin\",\n \"createdAt\": \"2025-10-05T11:30:45Z\",\n \"price\": 800,\n \"documentContentWordsChunked\": []\n },\n {\n \"ticketId\": \"TCK-1005\",\n \"title\": \"VPN access request\",\n \"description\": \"Remote employee needs VPN access to internal resources.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"network\",\n \"assignee\": \"tech support\",\n \"createdAt\": \"2025-11-10T07:20:10Z\",\n \"price\": 0,\n \"documentContentWordsChunked\": []\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 sorted by creation date.\"\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 24 high-priority network tickets assigned to tech support\n\nRephrased Query: List 24 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\": 24,\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": "semantic_question", "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: 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\": \"Login Issue on Mobile App\",\n \"author\": \"jdoe\",\n \"department\": \"Support\",\n \"createdAt\": \"2024-03-15T09:12:00Z\",\n \"fileType\": \"txt\",\n \"status\": \"open\",\n \"category\": \"authentication\",\n \"tags\": [\n \"mobile\",\n \"login\",\n \"urgent\"\n ],\n \"confidentialityLevel\": \"internal\"\n },\n {\n \"documentId\": \"TCKT-002\",\n \"title\": \"Request for Password Reset\",\n \"author\": \"asmith\",\n \"department\": \"Support\",\n \"createdAt\": \"2024-04-02T14:45:00Z\",\n \"fileType\": \"txt\",\n \"status\": \"closed\",\n \"category\": \"account\",\n \"tags\": [\n \"password\",\n \"reset\"\n ],\n \"confidentialityLevel\": \"internal\"\n },\n {\n \"documentId\": \"TCKT-003\",\n \"title\": \"Feature Request: Dark Mode\",\n \"author\": \"mbrown\",\n \"department\": \"Product\",\n \"createdAt\": \"2024-05-20T11:30:00Z\",\n \"fileType\": \"txt\",\n \"status\": \"open\",\n \"category\": \"feature_request\",\n \"tags\": [\n \"ui\",\n \"dark_mode\"\n ],\n \"confidentialityLevel\": \"public\"\n }\n]\n\nChat History:\n[]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"List recent tickets\",\n \"dsl_type\": \"hybrid_search\",\n \"dsl_query\": {\n \"size\": 10,\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 \"...\"\n ],\n \"k\": 10\n }\n }\n }\n ]\n }\n }\n }\n }\n]\n\nUser Query: Show tickets\n\nRephrased Query: List all support 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 \"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 }\n }\n }\n}" } ]
{ "domain": "Customer Support Tickets", "data_type": "unstructured", "query_type": "hybrid_search", "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\": \"IT 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 \"update\"\n ],\n \"confidentialityLevel\": \"internal\"\n },\n {\n \"documentId\": \"TCKT-002\",\n \"title\": \"Finance Quarterly Report Q1 2024\",\n \"author\": \"bob.jones\",\n \"department\": \"Finance\",\n \"createdAt\": \"2024-04-20T14:10: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\": \"TCKT-003\",\n \"title\": \"Remote Work Guidelines\",\n \"author\": \"carol.lee\",\n \"department\": \"Human Resources\",\n \"createdAt\": \"2023-11-05T08: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\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 \"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: 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 \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": \"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": "Customer Support Tickets", "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: 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\": \"Quarterly Financial Overview\",\n \"author\": \"alice.smith\",\n \"department\": \"Finance\",\n \"createdAt\": \"2024-02-15T09:30:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"report\",\n \"tags\": [\n \"finance\",\n \"quarterly\",\n \"overview\"\n ],\n \"confidentialityLevel\": \"internal\"\n },\n {\n \"documentId\": \"doc-002\",\n \"title\": \"Remote Work Policy Update\",\n \"author\": \"bob.johnson\",\n \"department\": \"HR\",\n \"createdAt\": \"2023-11-01T12:00:00Z\",\n \"fileType\": \"docx\",\n \"status\": \"draft\",\n \"category\": \"policy\",\n \"tags\": [\n \"remote\",\n \"policy\",\n \"HR\"\n ],\n \"confidentialityLevel\": \"public\"\n },\n {\n \"documentId\": \"doc-003\",\n \"title\": \"IT Security Guidelines\",\n \"author\": \"carol.lee\",\n \"department\": \"IT Security\",\n \"createdAt\": \"2024-01-20T15:45:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"guideline\",\n \"tags\": [\n \"security\",\n \"guidelines\",\n \"IT\"\n ],\n \"confidentialityLevel\": \"confidential\"\n },\n {\n \"documentId\": \"doc-004\",\n \"title\": \"Marketing Campaign Results 2023\",\n \"author\": \"dave.kumar\",\n \"department\": \"Marketing\",\n \"createdAt\": \"2024-03-05T08:20:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"report\",\n \"tags\": [\n \"marketing\",\n \"campaign\",\n \"2023\"\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\": \"Sure, retrieving approved IT Security policies...\"\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 \"query\": {\n \"hybrid\": {\n \"text\": \"approved policies\",\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 \"_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: Show PDF documents from the Finance department created 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 \"text\": \"PDF documents\",\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 \"gte\": \"2024-01-01T00:00:00Z\"\n }\n }\n },\n {\n \"term\": {\n \"status\": \"approved\"\n }\n }\n ]\n }\n }\n }\n }\n }\n}" } ]
{ "domain": "Corporate Blog Posts", "data_type": "unstructured", "query_type": "hybrid_search_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: Product Catalog 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 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 \"documentContentWordsChunked\": [\n {\n \"passage\": \"Network latency issue affecting VPN connectivity.\",\n \"embedding\": [\n 0,\n 0,\n \"...\"\n ]\n }\n ]\n },\n {\n \"ticketId\": \"TCK-1002\",\n \"title\": \"Software license renewal\",\n \"description\": \"Renewal of Adobe Creative Cloud licenses for design team.\",\n \"status\": \"resolved\",\n \"priority\": \"medium\",\n \"category\": \"software\",\n \"assignee\": \"procurement\",\n \"createdAt\": \"2025-09-15T14:42:10Z\",\n \"price\": 1200,\n \"documentContentWordsChunked\": [\n {\n \"passage\": \"Renewal of Adobe licenses for design department.\",\n \"embedding\": [\n 0,\n 0,\n \"...\"\n ]\n }\n ]\n },\n {\n \"ticketId\": \"TCK-1003\",\n \"title\": \"Defective printer replacement\",\n \"description\": \"Office printer model X123 is printing blank pages.\",\n \"status\": \"in_progress\",\n \"priority\": \"low\",\n \"category\": \"hardware\",\n \"assignee\": \"it_support\",\n \"createdAt\": \"2025-10-05T09:30:00Z\",\n \"price\": 250,\n \"documentContentWordsChunked\": [\n {\n \"passage\": \"Printer X123 producing blank pages, needs replacement.\",\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 your system.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"List resolved tickets from March\",\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 \"status\": \"resolved\"\n }\n },\n {\n \"range\": {\n \"createdAt\": {\n \"gte\": \"2025-03-01T00:00:00Z\",\n \"lt\": \"2025-04-01T00:00:00Z\"\n }\n }\n }\n ]\n }\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 high priority open tickets assigned to tech support\n\nRephrased Query: List open tickets with high priority 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 \"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": "pagination", "pattern_type": "specific_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: 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\": \"TCK-1001\",\n \"title\": \"Failed payment processing\",\n \"description\": \"Customer reported that payment was declined despite sufficient funds.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"payment\",\n \"assignee\": \"finance_team\",\n \"createdAt\": \"2025-10-20T09:15:00Z\",\n \"price\": 2500\n },\n {\n \"ticketId\": \"TCK-1002\",\n \"title\": \"Incorrect invoice amount\",\n \"description\": \"Invoice generated with wrong total for client XYZ.\",\n \"status\": \"resolved\",\n \"priority\": \"medium\",\n \"category\": \"billing\",\n \"assignee\": \"accounting\",\n \"createdAt\": \"2025-09-15T14:30:00Z\",\n \"price\": 0\n },\n {\n \"ticketId\": \"TCK-1003\",\n \"title\": \"Suspicious transaction alert\",\n \"description\": \"Transaction flagged for potential fraud on account 123456.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"fraud\",\n \"assignee\": \"risk_management\",\n \"createdAt\": \"2025-11-01T11:45:00Z\",\n \"price\": 12000\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Show tickets\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Here is a basic listing of 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 \"_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 open high-priority tickets assigned to finance team\n\nRephrased Query: Retrieve tickets where status is open, priority is high, 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 \"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": "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 Security Policy 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 \"policy\",\n \"quarterly\"\n ],\n \"confidentialityLevel\": \"internal\"\n },\n {\n \"documentId\": \"doc-002\",\n \"title\": \"Remote Work Guidelines\",\n \"author\": \"bob.jones\",\n \"department\": \"Human Resources\",\n \"createdAt\": \"2024-03-01T12: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 Annual Report 2024\",\n \"author\": \"carol.lee\",\n \"department\": \"Finance\",\n \"createdAt\": \"2024-01-20T08:15: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\": \"doc-004\",\n \"title\": \"IT Security Incident Response Plan\",\n \"author\": \"dave.kumar\",\n \"department\": \"IT Security\",\n \"createdAt\": \"2023-11-05T14:45: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 \"documentId\": \"doc-005\",\n \"title\": \"Marketing Campaign Overview Q4\",\n \"author\": \"eve.wilson\",\n \"department\": \"Marketing\",\n \"createdAt\": \"2024-09-10T10:00:00Z\",\n \"fileType\": \"pptx\",\n \"status\": \"approved\",\n \"category\": \"campaign\",\n \"tags\": [\n \"marketing\",\n \"Q4\",\n \"overview\"\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 from the IT Security department.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"List 10 recent blog posts\",\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 25 approved PDFs from IT Security department after 2023-12-31\n\nRephrased Query: Retrieve 25 approved PDF documents belonging to the IT Security department with a createdAt date later than 2023-12-31\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\": 25,\n \"from\": 25,\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 \"fileType\": \"pdf\"\n }\n },\n {\n \"term\": {\n \"department\": \"IT Security\"\n }\n },\n {\n \"range\": {\n \"createdAt\": {\n \"gt\": \"2023-12-31T00: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": "pagination", "pattern_type": "next_page", "size": 25, "from": 25, "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: 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\": \"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 },\n {\n \"ticketId\": \"SC-002\",\n \"title\": \"Software License Renewal\",\n \"description\": \"Renewal of enterprise software licenses for the supplier's accounting system.\",\n \"status\": \"closed\",\n \"priority\": \"medium\",\n \"category\": \"software\",\n \"assignee\": \"legal team\",\n \"createdAt\": \"2024-07-05T14:22:10Z\",\n \"price\": 45000\n },\n {\n \"ticketId\": \"SC-003\",\n \"title\": \"Supply Chain Risk Assessment\",\n \"description\": \"Assessment of risks in the supplier's supply chain for critical components.\",\n \"status\": \"in_progress\",\n \"priority\": \"high\",\n \"category\": \"risk\",\n \"assignee\": \"risk analyst\",\n \"createdAt\": \"2024-08-20T11:40:55Z\",\n \"price\": 30000\n }\n]\n\nChat History:\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 }\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: 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\": \"Company Remote Work Policy Update\",\n \"author\": \"jdoe\",\n \"department\": \"HR\",\n \"createdAt\": \"2024-03-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\": \"post-002\",\n \"title\": \"Cybersecurity Best Practices for Employees\",\n \"author\": \"asmith\",\n \"department\": \"IT Security\",\n \"createdAt\": \"2024-01-20T14:12:00Z\",\n \"fileType\": \"docx\",\n \"status\": \"approved\",\n \"category\": \"guideline\",\n \"tags\": [\n \"security\",\n \"password\",\n \"phishing\"\n ],\n \"confidentialityLevel\": \"internal\"\n },\n {\n \"documentId\": \"post-003\",\n \"title\": \"Annual Financial Report Q1 2024\",\n \"author\": \"mbrown\",\n \"department\": \"Finance\",\n \"createdAt\": \"2024-04-05T11:45:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"draft\",\n \"category\": \"report\",\n \"tags\": [\n \"finance\",\n \"Q1\",\n \"2024\"\n ],\n \"confidentialityLevel\": \"confidential\"\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Show recent posts\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, retrieving the latest documents for you.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"list all 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 recent posts\n\nRephrased Query: retrieve the most recent social media 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\": 0,\n \"query\": {\n \"bool\": {\n \"should\": [\n {\n \"match\": {\n \"title\": {\n \"query\": \"recent posts\",\n \"boost\": 2\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"avg\",\n \"query\": {\n \"knn\": {\n \"documentContentWordsChunked.embedding\": {\n \"vector\": [\n 0,\n 0,\n 0,\n \"...\"\n ],\n \"k\": 10\n }\n }\n }\n }\n }\n ],\n \"minimum_should_match\": 1\n }\n }\n }\n}" } ]
{ "domain": "social_media_posts", "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: 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 Maintenance Contract for Network Equipment\",\n \"description\": \"Contract covering yearly maintenance of all network routers and switches supplied by TechSupply Ltd.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"network\",\n \"assignee\": \"tech_support\",\n \"createdAt\": \"2024-09-12T08:15:30Z\",\n \"price\": 12500\n },\n {\n \"ticketId\": \"SC-1002\",\n \"title\": \"Software License Renewal for ERP System\",\n \"description\": \"Renewal of ERP software licenses for the finance department, valid for 3 years.\",\n \"status\": \"resolved\",\n \"priority\": \"medium\",\n \"category\": \"software\",\n \"assignee\": \"procurement_team\",\n \"createdAt\": \"2024-03-05T14:42:10Z\",\n \"price\": 48000\n },\n {\n \"ticketId\": \"SC-1003\",\n \"title\": \"Supply of Office Furniture\",\n \"description\": \"Purchase order for ergonomic chairs and desks for the new office wing.\",\n \"status\": \"in_progress\",\n \"priority\": \"low\",\n \"category\": \"office\",\n \"assignee\": \"logistics\",\n \"createdAt\": \"2024-07-21T11:00:00Z\",\n \"price\": 22000\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 Supplier Contracts index.\"\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 \"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 \"_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 high priority tickets 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 \"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: 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\": \"news-001\",\n \"title\": \"Company Announces New Remote Work Policy\",\n \"author\": \"jdoe\",\n \"department\": \"HR\",\n \"createdAt\": \"2024-03-15T09:30:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"published\",\n \"category\": \"Policy\",\n \"tags\": [\n \"remote\",\n \"work\",\n \"policy\"\n ],\n \"confidentialityLevel\": \"public\"\n },\n {\n \"documentId\": \"news-002\",\n \"title\": \"IT Security Updates: Zero‑Trust Architecture Rollout\",\n \"author\": \"asmith\",\n \"department\": \"IT Security\",\n \"createdAt\": \"2024-04-02T14:12:00Z\",\n \"fileType\": \"docx\",\n \"status\": \"published\",\n \"category\": \"Security\",\n \"tags\": [\n \"zero-trust\",\n \"architecture\",\n \"update\"\n ],\n \"confidentialityLevel\": \"internal\"\n },\n {\n \"documentId\": \"news-003\",\n \"title\": \"Finance Department Releases Q1 Earnings Report\",\n \"author\": \"mbrown\",\n \"department\": \"Finance\",\n \"createdAt\": \"2024-04-20T08:00:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"published\",\n \"category\": \"Report\",\n \"tags\": [\n \"earnings\",\n \"Q1\",\n \"finance\"\n ],\n \"confidentialityLevel\": \"public\"\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Can you show me the latest security related news?\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, here are the most recent articles about security.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"Show 10 latest news 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 $16 news articles about security policies\n\nRephrased Query: Retrieve sixteen news articles that discuss security policies\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\": 16,\n \"from\": 0,\n \"query\": {\n \"bool\": {\n \"should\": [\n {\n \"knn\": {\n \"documentContentWordsChunked.embedding\": {\n \"vector\": [\n 0,\n 0,\n \"...\"\n ],\n \"k\": 16\n }\n }\n },\n {\n \"match\": {\n \"title\": {\n \"query\": \"security policies\",\n \"operator\": \"and\"\n }\n }\n }\n ],\n \"minimum_should_match\": 1\n }\n }\n }\n}" } ]
{ "domain": "News Articles", "data_type": "unstructured", "query_type": "hybrid_search", "pattern": "refinement", "pattern_type": "add_filter", "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: 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-00123\",\n \"title\": \"Network latency issue\",\n \"description\": \"User reports intermittent latency on VPN connections.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"network\",\n \"assignee\": \"tech_support\",\n \"createdAt\": \"2024-10-05T08:15:30Z\",\n \"price\": 0,\n \"documentContentWordsChunked\": [\n {\n \"passage\": \"User experiences latency spikes during peak hours.\",\n \"embedding\": [\n 0,\n 0,\n 0,\n \"...\"\n ]\n }\n ]\n },\n {\n \"ticketId\": \"TCKT-00456\",\n \"title\": \"Billing discrepancy\",\n \"description\": \"Invoice shows an extra charge for premium support.\",\n \"status\": \"resolved\",\n \"priority\": \"medium\",\n \"category\": \"account\",\n \"assignee\": \"billing_team\",\n \"createdAt\": \"2024-09-20T14:42:10Z\",\n \"price\": 150.75,\n \"documentContentWordsChunked\": [\n {\n \"passage\": \"Customer was billed $20 more than expected.\",\n \"embedding\": [\n 0,\n 0,\n 0,\n \"...\"\n ]\n }\n ]\n },\n {\n \"ticketId\": \"TCKT-00789\",\n \"title\": \"Software installation failure\",\n \"description\": \"Installation script aborts with error code 503.\",\n \"status\": \"closed\",\n \"priority\": \"low\",\n \"category\": \"software\",\n \"assignee\": \"dev_ops\",\n \"createdAt\": \"2024-08-12T09:05:45Z\",\n \"price\": 0,\n \"documentContentWordsChunked\": [\n {\n \"passage\": \"The installer cannot reach the update server.\",\n \"embedding\": [\n 0,\n 0,\n 0,\n \"...\"\n ]\n }\n ]\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Can you show me the latest tickets?\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, here are the most recent tickets sorted by creation date.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"Show 10 recent 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: List 87 high-priority network tickets assigned to tech support\n\nRephrased Query: Retrieve 87 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\": 87,\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": "Customer Support Tickets", "data_type": "structured", "query_type": "listing_with_filters", "pattern": "initial", "pattern_type": "filtered_search", "size": 87, "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\": \"integer\"\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\": \"Jane Smith\",\n \"department\": \"IT Security\",\n \"createdAt\": \"2023-05-12T09:30:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"policy\",\n \"tags\": [\n \"security\",\n \"policy\",\n \"access\"\n ],\n \"confidentialityLevel\": 2\n },\n {\n \"documentId\": \"DOC-002\",\n \"title\": \"Remote Work Guidelines\",\n \"author\": \"Mark Johnson\",\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 \"guidelines\"\n ],\n \"confidentialityLevel\": 1\n },\n {\n \"documentId\": \"DOC-003\",\n \"title\": \"Finance Department Annual Report 2023\",\n \"author\": \"Laura Chen\",\n \"department\": \"Finance\",\n \"createdAt\": \"2024-02-28T11:00:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"report\",\n \"tags\": [\n \"finance\",\n \"annual\",\n \"2023\"\n ],\n \"confidentialityLevel\": 3\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\": \"Show tickets\",\n \"dsl_type\": \"keyword_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 from IT Security\n\nRephrased Query: list 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\",\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 \"should\": [\n {\n \"multi_match\": {\n \"query\": \"policy\",\n \"fields\": [\n \"title^2\",\n \"tags\"\n ],\n \"type\": \"best_fields\"\n }\n }\n ],\n \"minimum_should_match\": 0\n }\n }\n }\n}" } ]
{ "domain": "Legal Documents", "data_type": "unstructured", "query_type": "hybrid_search", "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\": \"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 Quarterly Report Q1 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 \"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-20T08: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\": \"Security Incident Response Procedure\",\n \"author\": \"dave.kumar\",\n \"department\": \"IT Security\",\n \"createdAt\": \"2024-07-05T11:45: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\": \"doc-005\",\n \"title\": \"Marketing Campaign Results 2023\",\n \"author\": \"eve.wang\",\n \"department\": \"Marketing\",\n \"createdAt\": \"2023-12-30T16:20:00Z\",\n \"fileType\": \"xlsx\",\n \"status\": \"approved\",\n \"category\": \"report\",\n \"tags\": [\n \"marketing\",\n \"campaign\",\n \"2023\"\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, I will retrieve the PDF documents from the Finance department created after January 1, 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 \"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 \"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 }\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 \"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 \"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": "refinement", "pattern_type": "change_sort", "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\": \"doc1\",\n \"title\": \"Wireless Earbuds Review\",\n \"author\": \"alice\",\n \"department\": \"Electronics\",\n \"createdAt\": \"2024-02-15T10:30:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"audio\",\n \"tags\": [\n \"wireless\",\n \"battery\",\n \"sound quality\"\n ],\n \"confidentialityLevel\": \"public\"\n },\n {\n \"documentId\": \"doc2\",\n \"title\": \"Smartphone Camera Comparison\",\n \"author\": \"bob\",\n \"department\": \"Electronics\",\n \"createdAt\": \"2024-05-20T14:45:00Z\",\n \"fileType\": \"docx\",\n \"status\": \"draft\",\n \"category\": \"mobile\",\n \"tags\": [\n \"camera\",\n \"resolution\",\n \"low light\"\n ],\n \"confidentialityLevel\": \"internal\"\n },\n {\n \"documentId\": \"doc3\",\n \"title\": \"Laptop Battery Life Test\",\n \"author\": \"carol\",\n \"department\": \"Computing\",\n \"createdAt\": \"2023-11-10T09:00:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"laptops\",\n \"tags\": [\n \"battery\",\n \"performance\",\n \"duration\"\n ],\n \"confidentialityLevel\": \"public\"\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Can you list the latest product reviews?\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, here are the most recent reviews...\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"List recent approved reviews from Electronics\",\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 \"status\": \"approved\"\n }\n },\n {\n \"term\": {\n \"department\": \"Electronics\"\n }\n }\n ]\n }\n }\n }\n }\n }\n }\n]\n\nUser Query: Show approved reviews from Electronics department\n\nRephrased Query: Retrieve approved product reviews where department 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\": \"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\": \"Electronics\"\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": "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: Research Papers 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 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\": \"Data Privacy Guidelines\",\n \"author\": \"bob.johnson\",\n \"department\": \"Legal\",\n \"createdAt\": \"2023-11-30\",\n \"fileType\": \"docx\",\n \"status\": \"draft\",\n \"category\": \"guideline\",\n \"tags\": [\n \"privacy\",\n \"data\",\n \"compliance\"\n ],\n \"confidentialityLevel\": \"confidential\"\n },\n {\n \"documentId\": \"doc-003\",\n \"title\": \"Remote Work Security Measures\",\n \"author\": \"carol.lee\",\n \"department\": \"IT Security\",\n \"createdAt\": \"2024-05-10\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"policy\",\n \"tags\": [\n \"remote\",\n \"security\",\n \"policy\"\n ],\n \"confidentialityLevel\": \"internal\"\n },\n {\n \"documentId\": \"doc-004\",\n \"title\": \"Financial Risk Assessment 2024\",\n \"author\": \"david.kim\",\n \"department\": \"Finance\",\n \"createdAt\": \"2024-01-20\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"report\",\n \"tags\": [\n \"finance\",\n \"risk\",\n \"2024\"\n ],\n \"confidentialityLevel\": \"restricted\"\n },\n {\n \"documentId\": \"doc-005\",\n \"title\": \"AI Ethics Whitepaper\",\n \"author\": \"eva.martinez\",\n \"department\": \"Research\",\n \"createdAt\": \"2023-09-05\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"whitepaper\",\n \"tags\": [\n \"AI\",\n \"ethics\",\n \"research\"\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, I can retrieve the approved policy documents for you. Do you need them filtered by any department or file type?\"\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 \"semantic\": {\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\": \"approved\"\n }\n },\n {\n \"term\": {\n \"category\": \"policy\"\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 }\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 \"semantic\": {\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\": \"approved\"\n }\n },\n {\n \"term\": {\n \"category\": \"policy\"\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": "Research Papers Repository", "data_type": "unstructured", "query_type": "hybrid_search_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: 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\": \"2024-01-15T08:30:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"active\",\n \"category\": \"Admission\",\n \"tags\": [\n \"patient\",\n \"admission\"\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-02-20T11:45:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"active\",\n \"category\": \"Report\",\n \"tags\": [\n \"x-ray\",\n \"chest\"\n ],\n \"confidentialityLevel\": \"medium\"\n },\n {\n \"documentId\": \"MR-003\",\n \"title\": \"Lab Results - Blood Panel\",\n \"author\": \"LabTech Carol\",\n \"department\": \"Pathology\",\n \"createdAt\": \"2024-03-05T14:20:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"archived\",\n \"category\": \"Lab\",\n \"tags\": [\n \"blood\",\n \"panel\"\n ],\n \"confidentialityLevel\": \"high\"\n },\n {\n \"documentId\": \"MR-004\",\n \"title\": \"Discharge Summary\",\n \"author\": \"Dr. David Kim\",\n \"department\": \"Cardiology\",\n \"createdAt\": \"2024-04-10T09:10:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"active\",\n \"category\": \"Summary\",\n \"tags\": [\n \"discharge\",\n \"cardiology\"\n ],\n \"confidentialityLevel\": \"high\"\n },\n {\n \"documentId\": \"MR-005\",\n \"title\": \"Medication Administration Record\",\n \"author\": \"Nurse Emma Jones\",\n \"department\": \"Oncology\",\n \"createdAt\": \"2024-05-01T07:55:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"active\",\n \"category\": \"Medication\",\n \"tags\": [\n \"medication\",\n \"oncology\"\n ],\n \"confidentialityLevel\": \"medium\"\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Show 16 recent documents\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, retrieving the latest 16 documents from the medical records index.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"List 10 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 16 recent documents\n\nRephrased Query: Retrieve 16 most recent 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\": 16,\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": 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: 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\": \"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\": \"Remote Work Guidelines\",\n \"author\": \"bob.jones\",\n \"department\": \"Human Resources\",\n \"createdAt\": \"2023-11-02T14:12: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-003\",\n \"title\": \"Financial Report Q1 2024\",\n \"author\": \"carol.lee\",\n \"department\": \"Finance\",\n \"createdAt\": \"2024-04-20T08:00:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"report\",\n \"tags\": [\n \"finance\",\n \"Q1\",\n \"2024\"\n ],\n \"confidentialityLevel\": \"confidential\"\n },\n {\n \"documentId\": \"doc-004\",\n \"title\": \"IT Security Incident Response Plan\",\n \"author\": \"dave.kumar\",\n \"department\": \"IT Security\",\n \"createdAt\": \"2024-01-10T11:45: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 \"documentId\": \"doc-005\",\n \"title\": \"Marketing Strategy 2025\",\n \"author\": \"eve.wilson\",\n \"department\": \"Marketing\",\n \"createdAt\": \"2024-06-05T10:20:00Z\",\n \"fileType\": \"pptx\",\n \"status\": \"approved\",\n \"category\": \"strategy\",\n \"tags\": [\n \"marketing\",\n \"2025\",\n \"strategy\"\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 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": "BlogPosts", "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: 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\": \"post-001\",\n \"title\": \"Understanding Remote Work Policies\",\n \"author\": \"alice.smith\",\n \"department\": \"HR\",\n \"createdAt\": \"2024-03-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\": \"post-002\",\n \"title\": \"Cybersecurity Best Practices for Employees\",\n \"author\": \"bob.johnson\",\n \"department\": \"IT Security\",\n \"createdAt\": \"2024-01-22T14:12:00Z\",\n \"fileType\": \"docx\",\n \"status\": \"approved\",\n \"category\": \"security\",\n \"tags\": [\n \"cybersecurity\",\n \"best practices\",\n \"employees\"\n ],\n \"confidentialityLevel\": \"internal\"\n },\n {\n \"documentId\": \"post-003\",\n \"title\": \"Annual Financial Report 2024\",\n \"author\": \"carol.lee\",\n \"department\": \"Finance\",\n \"createdAt\": \"2024-02-10T08:00:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"draft\",\n \"category\": \"report\",\n \"tags\": [\n \"finance\",\n \"annual\",\n \"2024\"\n ],\n \"confidentialityLevel\": \"confidential\"\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 posts for you.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"List blog posts\",\n \"dsl_type\": \"match_all\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"match_all\": {}\n }\n }\n }\n]\n\nUser Query: Show me the latest blog posts\n\nRephrased Query: List blog posts without specifying a count\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\": 10,\n \"query\": {\n \"bool\": {\n \"should\": [\n {\n \"multi_match\": {\n \"query\": \"latest blog posts\",\n \"fields\": [\n \"title^3\",\n \"tags^2\",\n \"category\"\n ],\n \"type\": \"best_fields\"\n }\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": "Blog Posts", "data_type": "unstructured", "query_type": "hybrid_search", "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: 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\": \"xlsx\",\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 2024\",\n \"author\": \"dave.kumar\",\n \"department\": \"Marketing\",\n \"createdAt\": \"2024-01-20T11: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\": \"IT Security Incident Response Procedure\",\n \"author\": \"eve.wilson\",\n \"department\": \"IT Security\",\n \"createdAt\": \"2024-03-05T16:10:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"procedure\",\n \"tags\": [\n \"security\",\n \"incident\",\n \"response\"\n ],\n \"confidentialityLevel\": \"internal\"\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 policy documents belonging to the IT Security department.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"Show draft reports from Finance after 2023-12-31\",\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\": \"draft\"\n }\n },\n {\n \"term\": {\n \"department\": \"Finance\"\n }\n },\n {\n \"range\": {\n \"createdAt\": {\n \"gt\": \"2023-12-31T00: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": "Social Media Posts", "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: 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.smith\",\n \"department\": \"IT Security\",\n \"createdAt\": \"2023-05-12T09: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.johnson\",\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.lee\",\n \"department\": \"IT Security\",\n \"createdAt\": \"2022-11-03T11: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 \"documentId\": \"TM-004\",\n \"title\": \"Software Deployment Process\",\n \"author\": \"dave.kumar\",\n \"department\": \"Engineering\",\n \"createdAt\": \"2023-08-15T08:45:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"process\",\n \"tags\": [\n \"deployment\",\n \"software\",\n \"process\"\n ],\n \"confidentialityLevel\": \"internal\"\n },\n {\n \"documentId\": \"TM-005\",\n \"title\": \"Incident Response Playbook\",\n \"author\": \"eve.martinez\",\n \"department\": \"IT Security\",\n \"createdAt\": \"2024-03-10T10:20:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"playbook\",\n \"tags\": [\n \"incident\",\n \"response\",\n \"security\"\n ],\n \"confidentialityLevel\": \"confidential\"\n }\n]\n\nChat History:\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\": {\n \"status\": \"approved\"\n }\n },\n {\n \"match\": {\n \"category\": \"policy\"\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": "Technical Manuals", "data_type": "unstructured", "query_type": "hybrid_search", "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-03-15T09:12: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 Connectivity Issue\",\n \"author\": \"asmith\",\n \"department\": \"Network Operations\",\n \"createdAt\": \"2024-04-02T14:45:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"closed\",\n \"category\": \"network\",\n \"tags\": [\n \"vpn\",\n \"connectivity\"\n ],\n \"confidentialityLevel\": \"confidential\"\n },\n {\n \"documentId\": \"TCKT-003\",\n \"title\": \"Software License Renewal\",\n \"author\": \"mbrown\",\n \"department\": \"Procurement\",\n \"createdAt\": \"2024-05-20T11:30:00Z\",\n \"fileType\": \"docx\",\n \"status\": \"in_progress\",\n \"category\": \"procurement\",\n \"tags\": [\n \"license\",\n \"renewal\"\n ],\n \"confidentialityLevel\": \"restricted\"\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, here are the open tickets...\"\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 support 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": "Customer Support Tickets", "data_type": "unstructured", "query_type": "hybrid_search", "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 \"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\": \"Onboarding paperwork missing\",\n \"description\": \"New hire did not receive onboarding documents.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"administration\",\n \"assignee\": \"HR Manager\",\n \"createdAt\": \"2025-10-20T09:15:00Z\",\n \"price\": 0\n },\n {\n \"ticketId\": \"TCK-002\",\n \"title\": \"Salary discrepancy for employee 12345\",\n \"description\": \"Monthly salary paid $200 less than contract.\",\n \"status\": \"in_progress\",\n \"priority\": \"medium\",\n \"category\": \"payroll\",\n \"assignee\": \"Payroll Specialist\",\n \"createdAt\": \"2025-10-18T14:30:00Z\",\n \"price\": 0\n },\n {\n \"ticketId\": \"TCK-003\",\n \"title\": \"Access request for HR portal\",\n \"description\": \"Employee needs read/write access to HR portal.\",\n \"status\": \"resolved\",\n \"priority\": \"low\",\n \"category\": \"access\",\n \"assignee\": \"IT Support\",\n \"createdAt\": \"2025-09-25T11:45:00Z\",\n \"price\": 0\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Can you list the tickets that are still open?\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, here are the open tickets...\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"List high priority payroll 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 \"priority\": \"high\"\n }\n },\n {\n \"term\": {\n \"category\": \"payroll\"\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 assigned to HR manager\n\nRephrased Query: List all tickets with status open and assignee HR Manager\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\": \"HR Manager\"\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": "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: 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 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\": \"post-002\",\n \"title\": \"Remote Work Guidelines\",\n \"author\": \"bob.jones\",\n \"department\": \"HR\",\n \"createdAt\": \"2024-01-20T14:12:00Z\",\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\": \"post-003\",\n \"title\": \"Finance Department Budget Report 2024\",\n \"author\": \"carol.lee\",\n \"department\": \"Finance\",\n \"createdAt\": \"2024-02-05T11:45:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"draft\",\n \"category\": \"report\",\n \"tags\": [\n \"budget\",\n \"2024\",\n \"finance\"\n ],\n \"confidentialityLevel\": \"confidential\"\n },\n {\n \"documentId\": \"post-004\",\n \"title\": \"IT Security Incident Response Playbook\",\n \"author\": \"dave.kumar\",\n \"department\": \"IT Security\",\n \"createdAt\": \"2024-04-01T08:00:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"playbook\",\n \"tags\": [\n \"incident\",\n \"response\",\n \"security\"\n ],\n \"confidentialityLevel\": \"internal\"\n },\n {\n \"documentId\": \"post-005\",\n \"title\": \"Marketing Campaign Overview\",\n \"author\": \"eve.wilson\",\n \"department\": \"Marketing\",\n \"createdAt\": \"2023-12-10T10:20:00Z\",\n \"fileType\": \"docx\",\n \"status\": \"approved\",\n \"category\": \"overview\",\n \"tags\": [\n \"campaign\",\n \"2024\",\n \"marketing\"\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 policy documents.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"Show 10 recent approved documents\",\n \"dsl_type\": \"simple_search\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match\": {\n \"status\": \"approved\"\n }\n }\n ]\n }\n },\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n }\n }\n }\n]\n\nUser Query: List 33 approved PDFs from Finance department after 2024-01-01\n\nRephrased Query: Retrieve 33 documents where status is approved, fileType is pdf, department is Finance, and createdAt is greater 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\": 33,\n \"from\": 0,\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"knn\": {\n \"field\": \"documentContentWordsChunked.embedding\",\n \"query_vector\": [\n 0,\n 0,\n \"...\"\n ],\n \"k\": 33,\n \"num_candidates\": 100\n }\n },\n {\n \"match\": {\n \"title\": {\n \"query\": \"approved pdf finance\",\n \"operator\": \"and\"\n }\n }\n }\n ],\n \"filter\": {\n \"bool\": {\n \"must\": [\n {\n \"term\": {\n \"status\": \"approved\"\n }\n },\n {\n \"term\": {\n \"fileType\": \"pdf\"\n }\n },\n {\n \"term\": {\n \"department\": \"Finance\"\n }\n }\n ],\n \"filter\": [\n {\n \"range\": {\n \"createdAt\": {\n \"gt\": \"2024-01-01T00:00:00Z\"\n }\n }\n }\n ]\n }\n }\n }\n }\n }\n}" } ]
{ "domain": "social_media_posts", "data_type": "unstructured", "query_type": "hybrid_search_with_filters", "pattern": "initial", "pattern_type": "sorted_listing", "size": 33, "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\": \"Global Economic Outlook 2025\",\n \"author\": \"Jane Smith\",\n \"department\": \"Finance\",\n \"createdAt\": \"2024-11-01T08:30:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"published\",\n \"category\": \"Economy\",\n \"tags\": [\n \"forecast\",\n \"global\",\n \"2025\"\n ],\n \"confidentialityLevel\": \"public\"\n },\n {\n \"documentId\": \"doc-002\",\n \"title\": \"Cybersecurity Best Practices\",\n \"author\": \"Alan Chen\",\n \"department\": \"IT Security\",\n \"createdAt\": \"2024-09-15T14:12:00Z\",\n \"fileType\": \"docx\",\n \"status\": \"approved\",\n \"category\": \"Security\",\n \"tags\": [\n \"policy\",\n \"remote work\",\n \"encryption\"\n ],\n \"confidentialityLevel\": \"internal\"\n },\n {\n \"documentId\": \"doc-003\",\n \"title\": \"Renewable Energy Initiatives\",\n \"author\": \"Maria Garcia\",\n \"department\": \"Environment\",\n \"createdAt\": \"2024-10-20T10:45:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"draft\",\n \"category\": \"Energy\",\n \"tags\": [\n \"solar\",\n \"wind\",\n \"sustainability\"\n ],\n \"confidentialityLevel\": \"public\"\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Show me the latest news articles about climate change.\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, I will retrieve the most recent articles related to climate change.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"list all 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 a list of tickets without any filters or count specification\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 \"multi_match\": {\n \"query\": \"tickets\",\n \"fields\": [\n \"title^3\",\n \"tags\",\n \"category\"\n ]\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"avg\",\n \"query\": {\n \"knn\": {\n \"documentContentWordsChunked.embedding\": {\n \"vector\": [\n 0,\n 0,\n \"...\"\n ],\n \"k\": 10\n }\n }\n }\n }\n }\n ],\n \"minimum_should_match\": 1\n }\n }\n }\n}" } ]
{ "domain": "News Articles", "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: 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 data center\",\n \"description\": \"Investigate and resolve the network outage affecting servers.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"network\",\n \"assignee\": \"Alice\",\n \"createdAt\": \"2025-10-20T08:15:00Z\",\n \"price\": 0\n },\n {\n \"ticketId\": \"TCK-002\",\n \"title\": \"Update project documentation\",\n \"description\": \"Add the latest sprint details to the project wiki.\",\n \"status\": \"in_progress\",\n \"priority\": \"medium\",\n \"category\": \"documentation\",\n \"assignee\": \"Bob\",\n \"createdAt\": \"2025-10-18T14:30:00Z\",\n \"price\": 0\n },\n {\n \"ticketId\": \"TCK-003\",\n \"title\": \"Bug fix for login module\",\n \"description\": \"Resolve the authentication error reported by users.\",\n \"status\": \"resolved\",\n \"priority\": \"high\",\n \"category\": \"software\",\n \"assignee\": \"Charlie\",\n \"createdAt\": \"2025-09-30T10:45:00Z\",\n \"price\": 0\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Show open tickets assigned to Alice\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, retrieving open tickets where the assignee is Alice.\"\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 assigned to Alice\n\nRephrased Query: List open tickets where assignee is 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 \"assignee\": \"Alice\"\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": "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 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\": \"P001\",\n \"title\": \"Network Router\",\n \"description\": \"High‑performance router for enterprise networks.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"network\",\n \"assignee\": \"tech_support\",\n \"createdAt\": \"2023-03-12T08:15:30Z\",\n \"price\": 299.99\n },\n {\n \"productId\": \"P002\",\n \"title\": \"Account Management Software\",\n \"description\": \"Software for managing customer accounts and billing.\",\n \"status\": \"resolved\",\n \"priority\": \"medium\",\n \"category\": \"account\",\n \"assignee\": \"john_doe\",\n \"createdAt\": \"2023-03-20T14:42:10Z\",\n \"price\": 1499\n },\n {\n \"productId\": \"P003\",\n \"title\": \"Security Camera\",\n \"description\": \"Indoor security camera with night vision.\",\n \"status\": \"closed\",\n \"priority\": \"low\",\n \"category\": \"security\",\n \"assignee\": \"jane_smith\",\n \"createdAt\": \"2023-02-28T10:05:45Z\",\n \"price\": 89.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 tickets that are currently open.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"List high priority 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 \"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: Get resolved tickets from March in Account category\n\nRephrased Query: List resolved tickets created in March that belong to the Account 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\": \"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\": \"resolved\"\n }\n },\n {\n \"range\": {\n \"createdAt\": {\n \"gte\": \"2023-03-01\",\n \"lte\": \"2023-03-31\"\n }\n }\n },\n {\n \"term\": {\n \"category\": \"account\"\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": "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: 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\": \"Global Economic Outlook 2025\",\n \"author\": \"Jane Smith\",\n \"department\": \"Finance\",\n \"createdAt\": \"2024-11-01T08:30:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"published\",\n \"category\": \"Economy\",\n \"tags\": [\n \"economy\",\n \"forecast\",\n \"2025\"\n ],\n \"confidentialityLevel\": \"public\"\n },\n {\n \"documentId\": \"doc-002\",\n \"title\": \"Cybersecurity Best Practices\",\n \"author\": \"Alan Chen\",\n \"department\": \"IT Security\",\n \"createdAt\": \"2024-09-15T14:12:00Z\",\n \"fileType\": \"docx\",\n \"status\": \"approved\",\n \"category\": \"Security\",\n \"tags\": [\n \"security\",\n \"policy\",\n \"remote work\"\n ],\n \"confidentialityLevel\": \"internal\"\n },\n {\n \"documentId\": \"doc-003\",\n \"title\": \"Climate Change Impact Report\",\n \"author\": \"Maria Garcia\",\n \"department\": \"Environment\",\n \"createdAt\": \"2024-10-20T10:45:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"draft\",\n \"category\": \"Environment\",\n \"tags\": [\n \"climate\",\n \"report\",\n \"2024\"\n ],\n \"confidentialityLevel\": \"restricted\"\n }\n]\n\nChat History:\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 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 \"bool\": {\n \"should\": [\n {\n \"match_all\": {}\n },\n {\n \"knn\": {\n \"field\": \"documentContentWordsChunked.embedding\",\n \"query_vector\": [],\n \"k\": 10,\n \"num_candidates\": 100\n }\n }\n ],\n \"minimum_should_match\": 1\n }\n }\n }\n}" } ]
{ "domain": "News Articles", "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: 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 rules.\",\n \"status\": \"open\",\n \"priority\": \"medium\",\n \"category\": \"setup\",\n \"assignee\": \"alice\",\n \"createdAt\": \"2024-10-01T09: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 and reporting pages.\",\n \"status\": \"in_progress\",\n \"priority\": \"high\",\n \"category\": \"design\",\n \"assignee\": \"bob\",\n \"createdAt\": \"2024-10-03T14:42:00Z\",\n \"price\": 0\n },\n {\n \"ticketId\": \"TCK-003\",\n \"title\": \"Implement authentication\",\n \"description\": \"Add OAuth2 login flow using the company SSO provider.\",\n \"status\": \"closed\",\n \"priority\": \"high\",\n \"category\": \"development\",\n \"assignee\": \"carol\",\n \"createdAt\": \"2024-09-28T11:07:00Z\",\n \"price\": 0\n },\n {\n \"ticketId\": \"TCK-004\",\n \"title\": \"Prepare project budget\",\n \"description\": \"Calculate estimated costs for resources, licenses, and cloud services for Q1.\",\n \"status\": \"open\",\n \"priority\": \"low\",\n \"category\": \"finance\",\n \"assignee\": \"dave\",\n \"createdAt\": \"2024-10-05T08:30:00Z\",\n \"price\": 0\n }\n]\n\nChat History:\n[]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"List 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": "Project Management Tasks", "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: 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\": \"Login Issue – Unable to Access Account\",\n \"author\": \"jdoe\",\n \"department\": \"IT Support\",\n \"createdAt\": \"2024-03-15T09:12:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"open\",\n \"category\": \"authentication\",\n \"tags\": [\n \"login\",\n \"access\",\n \"urgent\"\n ],\n \"confidentialityLevel\": \"internal\"\n },\n {\n \"documentId\": \"TCKT-002\",\n \"title\": \"Request for Software Installation – Photoshop\",\n \"author\": \"asmith\",\n \"department\": \"Design\",\n \"createdAt\": \"2024-04-02T14:45:00Z\",\n \"fileType\": \"docx\",\n \"status\": \"closed\",\n \"category\": \"software_request\",\n \"tags\": [\n \"photoshop\",\n \"installation\"\n ],\n \"confidentialityLevel\": \"internal\"\n },\n {\n \"documentId\": \"TCKT-003\",\n \"title\": \"Network Outage Report – Building A\",\n \"author\": \"mlee\",\n \"department\": \"Network Operations\",\n \"createdAt\": \"2024-05-20T08:30:00Z\",\n \"fileType\": \"txt\",\n \"status\": \"resolved\",\n \"category\": \"network\",\n \"tags\": [\n \"outage\",\n \"building A\"\n ],\n \"confidentialityLevel\": \"public\"\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Can you list all open tickets for the IT Support department?\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, here are the open tickets in IT Support...\"\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 \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"query\": {\n \"bool\": {\n \"should\": [\n {\n \"match_all\": {}\n },\n {\n \"knn\": {\n \"documentContentWordsChunked.embedding\": {\n \"vector\": [\n 0,\n 0,\n \"...\"\n ],\n \"k\": 10\n }\n }\n }\n ]\n }\n }\n }\n }\n]\n\nUser Query: Show tickets\n\nRephrased Query: List all support 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 \"bool\": {\n \"should\": [\n {\n \"match_all\": {}\n },\n {\n \"knn\": {\n \"documentContentWordsChunked.embedding\": {\n \"vector\": [\n 0,\n 0,\n \"...\"\n ],\n \"k\": 10\n }\n }\n }\n ]\n }\n }\n }\n}" } ]
{ "domain": "Customer Support Tickets", "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: 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\": \"2023-11-15\",\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\": \"DOC-002\",\n \"title\": \"Finance Department – Expense Reimbursement Guidelines\",\n \"author\": \"bob.jones\",\n \"department\": \"Finance\",\n \"createdAt\": \"2024-02-10\",\n \"fileType\": \"pdf\",\n \"status\": \"draft\",\n \"category\": \"guideline\",\n \"tags\": [\n \"expense\",\n \"reimbursement\"\n ],\n \"confidentialityLevel\": \"confidential\"\n },\n {\n \"documentId\": \"DOC-003\",\n \"title\": \"Remote Work Security Checklist\",\n \"author\": \"carol.lee\",\n \"department\": \"IT Security\",\n \"createdAt\": \"2024-07-01\",\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\": \"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\": \"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 0,\n 0,\n 0,\n \"...\"\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 }\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\": 30,\n \"query\": {\n \"hybrid\": {\n \"vector\": {\n \"field\": \"documentContentWordsChunked.embedding\",\n \"query_vector\": [\n 0,\n 0,\n 0,\n \"...\"\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}" } ]
{ "domain": "Legal Documents", "data_type": "unstructured", "query_type": "hybrid_search_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: 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\": \"User 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\": \"User reports intermittent latency on VPN connections.\",\n \"embedding\": [\n 0,\n 0,\n 0\n ]\n }\n ]\n },\n {\n \"ticketId\": \"TCK-1002\",\n \"title\": \"Printer out of toner\",\n \"description\": \"Office printer in room 402 is out of toner and needs replacement.\",\n \"status\": \"closed\",\n \"priority\": \"low\",\n \"category\": \"hardware\",\n \"assignee\": \"facility_team\",\n \"createdAt\": \"2025-09-15T14:42:10Z\",\n \"price\": 0,\n \"documentContentWordsChunked\": [\n {\n \"passage\": \"Office printer in room 402 is out of toner and needs replacement.\",\n \"embedding\": [\n 0,\n 0,\n 0\n ]\n }\n ]\n },\n {\n \"ticketId\": \"TCK-1003\",\n \"title\": \"Software license renewal\",\n \"description\": \"Renewal needed for Adobe Creative Cloud licenses for design team.\",\n \"status\": \"in_progress\",\n \"priority\": \"medium\",\n \"category\": \"software\",\n \"assignee\": \"procurement\",\n \"createdAt\": \"2025-11-01T09:05:45Z\",\n \"price\": 1200,\n \"documentContentWordsChunked\": [\n {\n \"passage\": \"Renewal needed for Adobe Creative Cloud licenses for design team.\",\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 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 }\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": "Inventory Items", "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\": \"Login Issue – Unable to access account\",\n \"author\": \"jdoe\",\n \"department\": \"IT Support\",\n \"createdAt\": \"2024-03-15T09:12:00Z\",\n \"fileType\": \"txt\",\n \"status\": \"open\",\n \"category\": \"authentication\",\n \"tags\": [\n \"login\",\n \"access\",\n \"urgent\"\n ],\n \"confidentialityLevel\": \"internal\"\n },\n {\n \"documentId\": \"TCKT-002\",\n \"title\": \"Request for Software License Renewal\",\n \"author\": \"asmith\",\n \"department\": \"Finance\",\n \"createdAt\": \"2024-04-02T14:45:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"closed\",\n \"category\": \"procurement\",\n \"tags\": [\n \"license\",\n \"renewal\",\n \"software\"\n ],\n \"confidentialityLevel\": \"confidential\"\n },\n {\n \"documentId\": \"TCKT-003\",\n \"title\": \"Remote Work Policy Clarification\",\n \"author\": \"mbrown\",\n \"department\": \"HR\",\n \"createdAt\": \"2024-05-20T11:30:00Z\",\n \"fileType\": \"docx\",\n \"status\": \"in_progress\",\n \"category\": \"policy\",\n \"tags\": [\n \"remote\",\n \"policy\",\n \"question\"\n ],\n \"confidentialityLevel\": \"public\"\n },\n {\n \"documentId\": \"TCKT-004\",\n \"title\": \"Security Incident – Phishing Email Reported\",\n \"author\": \"cwilson\",\n \"department\": \"IT Security\",\n \"createdAt\": \"2024-06-01T08:05:00Z\",\n \"fileType\": \"eml\",\n \"status\": \"open\",\n \"category\": \"security\",\n \"tags\": [\n \"phishing\",\n \"incident\",\n \"email\"\n ],\n \"confidentialityLevel\": \"restricted\"\n },\n {\n \"documentId\": \"TCKT-005\",\n \"title\": \"Feedback on New Ticketing System\",\n \"author\": \"lgreen\",\n \"department\": \"Customer Service\",\n \"createdAt\": \"2024-06-10T16:20:00Z\",\n \"fileType\": \"txt\",\n \"status\": \"closed\",\n \"category\": \"feedback\",\n \"tags\": [\n \"ui\",\n \"usability\",\n \"suggestion\"\n ],\n \"confidentialityLevel\": \"internal\"\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Can you list the recent tickets from IT Support?\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, here are the latest tickets from the IT Support department...\"\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 support 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_all\": {}\n },\n {\n \"knn\": {\n \"documentContentWordsChunked.embedding\": {\n \"vector\": [\n 0,\n 0,\n 0\n ],\n \"k\": 10\n }\n }\n }\n ]\n }\n }\n }\n}" } ]
{ "domain": "Customer Support Tickets", "data_type": "unstructured", "query_type": "hybrid_search", "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: 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 Incident Response Guide\",\n \"author\": \"bob.johnson\",\n \"department\": \"IT Security\",\n \"createdAt\": \"2023-11-01T14:45:00Z\",\n \"fileType\": \"docx\",\n \"status\": \"approved\",\n \"category\": \"guide\",\n \"tags\": [\n \"security\",\n \"incident\",\n \"response\"\n ],\n \"confidentialityLevel\": \"internal\"\n },\n {\n \"documentId\": \"doc-003\",\n \"title\": \"Finance Department Quarterly Report Q3 2024\",\n \"author\": \"carol.lee\",\n \"department\": \"Finance\",\n \"createdAt\": \"2024-10-05T08:00: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\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Can you list all the approved policies?\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, here are the approved policies: ...\"\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 }\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\": \"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 \"knn\": {\n \"documentContentWordsChunked.embedding\": {\n \"vector\": [\n 0,\n 0,\n 0,\n \"...\"\n ],\n \"k\": 10,\n \"num_candidates\": 100\n }\n }\n },\n {\n \"match_all\": {}\n }\n ],\n \"minimum_should_match\": 1\n }\n }\n }\n}" } ]
{ "domain": "BlogPosts", "data_type": "unstructured", "query_type": "hybrid_search", "pattern": "initial", "pattern_type": "listing", "size": 10, "from": 0, "is_pagination": false }