sp-dev-docs icon indicating copy to clipboard operation
sp-dev-docs copied to clipboard

Why using alias in KQL does no give me results

Open FranBor opened this issue 2 years ago • 3 comments

What type of issue is this?

Question

What SharePoint development model, framework, SDK or API is this about?

SharePoint CSOM

Target SharePoint environment

SharePoint Online

What browser(s) / client(s) have you tested

  • [ ] 💥 Internet Explorer
  • [ ] 💥 Microsoft Edge
  • [X] 💥 Google Chrome
  • [ ] 💥 FireFox
  • [ ] 💥 Safari
  • [ ] mobile (iOS/iPadOS)
  • [ ] mobile (Android)
  • [ ] not applicable
  • [ ] other (enter in the "Additional environment details" area below)

Additional environment details

  • browser version: 103.0.5060.53 (Build ufficiale) (a 64 bit)
  • Microsoft.SharePointOnline.CSOM: 16.1.21213.12000

Issue description

I have a Number column with the internal name IdDocSet. On the managed properties page I edited the property RefinableDecimal01 with alias IdDocSet and mapping ows_IdDocSet.

image

Below is the piece of code I use for research

KeywordQuery keywordQuery = new KeywordQuery(context);
keywordQuery.QueryText = "path:https://{MyDocumentLibraryUrl} AND (ContentTypeId:0x0120D520* OR ContentTypeId:0x0101*)";

keywordQuery.CollapseSpecification = "IdDocSet";

keywordQuery.SelectProperties.Add("IdDocSet");

keywordQuery.SortList.Add("IdDocSet", SortDirection.Descending);

SearchExecutor searchExec = new SearchExecutor(context);
ClientResult<ResultTableCollection> resultTableColl = searchExec.ExecuteQuery(keywordQuery);
context.ExecuteQueryRetry();

When I run the code i get the error below:

  Microsoft.SharePoint.Client.ServerException: Search has encountered a problem that prevents results from being returned.  If the issue persists, please contact your administrator.
   at Microsoft.SharePoint.Client.ClientRequest.ProcessResponseStream(Stream responseStream)
   at Microsoft.SharePoint.Client.ClientRequest.ProcessResponse()
   at Microsoft.SharePoint.Client.ClientRequest.<ExecuteQueryToServerAsync>d__53.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.SharePoint.Client.ClientRequest.<ExecuteQueryAsync>d__39.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.SharePoint.Client.ClientRuntimeContext.<ExecuteQueryAsync>d__65.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.SharePoint.Client.ClientContext.<ExecuteQueryAsync>d__28.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at Microsoft.SharePoint.Client.ClientContextExtensions.<ExecuteQueryImplementation>d__7.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.SharePoint.Client.ClientContextExtensions.ExecuteQueryRetry(ClientRuntimeContext clientContext, Int32 retryCount, Int32 delay, String userAgent)

If I run the same code using "RefinableDecimal01" instead of the "IdDocSet", it works fine.

I need to use the alias in my code, please help me.

FranBor avatar Jun 24 '22 10:06 FranBor

Thank you for reporting this issue. We will be triaging your incoming issue as soon as possible.

ghost avatar Jun 24 '22 10:06 ghost

Any news? I also tried using the SharePoint REST API v1

    https://{{SPSiteUrl}}/_api/search/query?querytext='test'&selectproperties='Title,IdDocSet'

And I get the error below:

       {
            "odata.error": {
                "code": "-1, Microsoft.Office.Server.Search.REST.SearchServiceException",
                "message": {
                    "lang": "en-US",
                    "value": "An unknown error occurred."
                }
            }
        }

If I use "RefinableDecimal01" instead of the "IdDocSet", it works fine.

    https://{{SPSiteUrl}}/_api/search/query?querytext='test'&selectproperties='Title,RefinableDecimal01'

FranBor avatar Jun 30 '22 15:06 FranBor

This seems to be resolved when I test. @FranBor can you re-test?

wobba avatar Aug 19 '22 07:08 wobba

Resolved.

wobba avatar Sep 15 '22 18:09 wobba

Issues that have been closed & had no follow-up activity for at least 7 days are automatically locked. Please refer to our wiki for more details, including how to remediate this action if you feel this was done prematurely or in error: Issue List: Our approach to locked issues

ghost avatar Sep 23 '22 00:09 ghost