{"record":{"id":"c5265f3a79835fc5","repo":"OrchardCMS/OrchardCore","slug":"an-ambiguous-index-has-been-found","errorCode":null,"errorMessage":"An ambiguous index has been found.","messagePattern":"An ambiguous index has been found\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/OrchardCore/OrchardCore.ContentManagement.GraphQL/Queries/ContentItemsFieldType.cs","lineNumber":163,"sourceCode":"        predicateQuery.CreateTableAlias(nameof(ContentItemIndex), defaultTableAlias);\n\n        // Add all provided table alias to the current predicate query.\n        var providers = fieldContext.RequestServices.GetServices<IIndexAliasProvider>();\n        var indexes = new Dictionary<string, IndexAlias>(StringComparer.OrdinalIgnoreCase);\n        var indexAliases = new HashSet<string>(StringComparer.OrdinalIgnoreCase);\n\n        foreach (var aliasProvider in providers)\n        {\n            foreach (var alias in await aliasProvider.GetAliasesAsync())\n            {\n                predicateQuery.CreateAlias(alias.Alias, alias.Index, alias.IsPartial);\n                if (indexAliases.Add(alias.Alias))\n                {\n                    if (!indexes.TryAdd(alias.Index, alias))\n                    {\n                        if (indexes[alias.Index].IndexType != alias.IndexType)\n                        {\n                            throw new InvalidOperationException(\"An ambiguous index has been found.\");\n                        }\n                    }\n                }\n            }\n        }\n\n        var expressions = Expression.Conjunction();\n\n        var whereInput = (IFilterInputObjectGraphType)fieldContext.FieldDefinition.Arguments.FirstOrDefault(x => x.Name == \"where\")?.ResolvedType;\n\n        BuildWhereExpressions(where, expressions, null, whereInput, indexAliases);\n\n        expressions.SearchUsedAlias(predicateQuery);\n\n        // Add all Indexes that were used in the predicate query.\n        IQuery<ContentItem> contentQuery = query;\n        foreach (var usedAlias in predicateQuery.GetUsedAliases())\n        {","sourceCodeStart":145,"sourceCodeEnd":181,"githubUrl":"https://github.com/OrchardCMS/OrchardCore/blob/4306c0717fe573f6fca1b4955909ddab6a192807/src/OrchardCore/OrchardCore.ContentManagement.GraphQL/Queries/ContentItemsFieldType.cs#L145-L181","documentation":"When building the ContentItems GraphQL query, aliases collected for the same index (same Index key) must agree on IndexType. If two aliased paths map to the same index name but different index types, the query would produce contradictory table bindings, so an InvalidOperationException('An ambiguous index has been found.') is thrown in FilterWhereArgumentsAsync.","triggerScenarios":"A GraphQL where-input uses two aliased paths (e.g. two fields or two index profiles) whose resolved alias.Index is identical but whose IndexType differs — typically two index profiles with the same index name configured with different index types (SQL vs Lucene, or different profile types).","commonSituations":"Two ContentIndex profiles named the same for different providers; custom index handlers emitting colliding index names; merging where-clauses across modules that both register aliases for the same index name.","solutions":["Rename one of the conflicting indexes so each index name maps to exactly one index type.","Change the GraphQL query to use a single alias/path for that index.","Align the IndexType of the duplicated profiles in the indexing settings."],"exampleFix":"// before\n// two profiles: \"BlogPostIndex\" (type Sql) and \"BlogPostIndex\" (type Lucene)\n// after\n// rename one to \"BlogPostSqlIndex\" or remove the duplicate profile","handlingStrategy":"validation","validationCode":"// pre-check before building the query: ensure each index name maps to one index type\nvar dupes = aliases.GroupBy(a => a.Index).Where(g => g.Select(x => x.IndexType).Distinct().Count() > 1).ToList();\nif (dupes.Any()) throw new InvalidOperationException($\"Ambiguous indexes: {string.Join(\",\", dupes.Select(d => d.Key))}\");","typeGuard":null,"tryCatchPattern":"try { var result = await query.FilterWhereArgumentsAsync(...); }\ncatch (InvalidOperationException ex) when (ex.Message == \"An ambiguous index has been found.\") { _logger.LogError(ex, \"Duplicate index name with differing index types in GraphQL where-input\"); throw; }","preventionTips":["Keep index profile names unique across providers and modules.","Review custom index handlers for name collisions.","Document index ownership per module to avoid cross-module clashes."],"tags":["graphql","indexing","ambiguity","query"],"backgroundTag":"internal-invariant-violation","analyzedSha":"4306c0717fe573f6fca1b4955909ddab6a192807","analyzedAt":"2026-09-13T17:41:05.024Z","contentChangedAt":"2026-09-13T17:41:05.024Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}