Forum Discussion
Jedrek96
Aug 23, 2023Copper Contributor
Unable to Retrieve Search Queries from Sharepoint
I am currently having difficulties retrieving the queries for my sharepoint API. I am not sure why my query isn't retrieving anything at all. Please do assist... is there any configurations that I should look out for?
For eg.
http://www.test.com/_api/search/query?querytext=%27Document%27 http://www.test.com/_api/search/query?querytext=%27title:%22Report%22%27
This is my XML file.
<feed xmlns="http://www.w3.org/2005/Atom"> <entry> <id>1</id> <title type="text">Document Title 1</title> <content type="text">This is the content of document 1.</content> </entry> <entry> <id>2</id> <title type="text">Document Title 2</title> <content type="text">This is the content of document 2.</content> </entry> </feed>
My response:
This XML file does not appear to have any style information associated with it. The document tree is shown below.
<d:query xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns:georss="http://www.georss.org/georss" xmlns:gml="http://www.opengis.net/gml" m:type="Microsoft.Office.Server.Search.REST.SearchResult"> <d:ElapsedTime m:type="Edm.Int32">28</d:ElapsedTime> <d:PrimaryQueryResult m:type="Microsoft.Office.Server.Search.REST.QueryResult"> <d:CustomResults m:type="Collection(Microsoft.Office.Server.Search.REST.CustomResult)"/> <d:QueryId>30e63190-ef8d-4dbe-bfd8-4f1b6df8e5d8</d:QueryId> <d:QueryRuleId m:type="Edm.Guid">00000000-0000-0000-0000-000000000000</d:QueryRuleId> <d:RefinementResults m:null="true"/> <d:RelevantResults m:type="Microsoft.Office.Server.Search.REST.RelevantResults"> <d:GroupTemplateId m:null="true"/> <d:ItemTemplateId m:null="true"/> <d:Properties m:type="Collection(SP.KeyValue)"> <d:element> <d:Key>GenerationId</d:Key> <d:Value>9223372036854775806</d:Value> <d:ValueType>Edm.Int64</d:ValueType> </d:element> <d:element> <d:Key>indexSystem</d:Key> <d:Value/> <d:ValueType>Edm.String</d:ValueType> </d:element> <d:element> <d:Key>ExecutionTimeMs</d:Key> <d:Value>0</d:Value> <d:ValueType>Edm.Int32</d:ValueType> </d:element> <d:element> <d:Key>QueryModification</d:Key> <d:Value>title:"Report" -ContentClass=urn:content-class:People</d:Value> <d:ValueType>Edm.String</d:ValueType> </d:element> <d:element> <d:Key>RenderTemplateId</d:Key> <d:Value>~sitecollection/_catalogs/masterpage/Display Templates/Search/Group_Default.js</d:Value> <d:ValueType>Edm.String</d:ValueType> </d:element> <d:element> <d:Key>StartRecord</d:Key> <d:Value>0</d:Value> <d:ValueType>Edm.Int32</d:ValueType> </d:element> <d:element> <d:Key>IsFirstBlockInSubstrate</d:Key> <d:Value>true</d:Value> <d:ValueType>Edm.Boolean</d:ValueType> </d:element> <d:element> <d:Key>IsLastBlockInSubstrate</d:Key> <d:Value>true</d:Value> <d:ValueType>Edm.Boolean</d:ValueType> </d:element> </d:Properties> <d:ResultTitle m:null="true"/> <d:ResultTitleUrl m:null="true"/> <d:RowCount m:type="Edm.Int32">0</d:RowCount> <d:Table m:type="SP.SimpleDataTable"> <d:Rows/> </d:Table> <d:TotalRows m:type="Edm.Int32">0</d:TotalRows> <d:TotalRowsIncludingDuplicates m:type="Edm.Int32">0</d:TotalRowsIncludingDuplicates> </d:RelevantResults> <d:SpecialTermResults m:null="true"/> </d:PrimaryQueryResult> <d:Properties m:type="Collection(SP.KeyValue)"> <d:element> <d:Key>RowLimit</d:Key> <d:Value>10</d:Value> <d:ValueType>Edm.Int32</d:ValueType> </d:element> <d:element> <d:Key>SourceId</d:Key> <d:Value>12345678-2156-4e00-1234-6d20c2f2231</d:Value> <d:ValueType>Edm.Guid</d:ValueType> </d:element> <d:element> <d:Key>CorrelationId</d:Key> <d:Value>12345678-1234-5678-1234-6d20c331aec6</d:Value> <d:ValueType>Edm.Guid</d:ValueType> </d:element> <d:element> <d:Key>WasGroupRestricted</d:Key> <d:Value>false</d:Value> <d:ValueType>Edm.Boolean</d:ValueType> </d:element> <d:element> <d:Key>IsPartial</d:Key> <d:Value>false</d:Value> <d:ValueType>Edm.Boolean</d:ValueType> </d:element> <d:element> <d:Key>EnableInterleaving</d:Key> <d:Value>true</d:Value> <d:ValueType>Edm.Boolean</d:ValueType> </d:element> <d:element> <d:Key>piPageImpression</d:Key> <d:Value>2139_1234_1234</d:Value> <d:ValueType>Edm.String</d:ValueType> </d:element> <d:element> <d:Key>SerializedQuery</d:Key> <d:Value><Query Culture="en-US" EnableStemming="True" EnablePhonetic="False" EnableNicknames="False" IgnoreAllNoiseQuery="True" SummaryLength="180" MaxSnippetLength="180" DesiredSnippetLength="90" KeywordInclusion="0" QueryText="title:"Report"" QueryTemplate="" TrimDuplicates="True" Site="****" Web="****" KeywordType="True" HiddenConstraints="" /></d:Value> <d:ValueType>Edm.String</d:ValueType> </d:element> </d:Properties> <d:SecondaryQueryResults m:type="Collection(Microsoft.Office.Server.Search.REST.QueryResult)"/> <d:SpellingSuggestion/> <d:TriggeredRules m:type="Collection(Edm.Guid)"/> </d:query>
Search Service Application: Edit Content Source
This are the configurations to enable continuous crawl for a new content
Part1
Part2
Hi Jedrek96 ,
It seems like that content source is not indexing anything.
You need to enable either an incremental crawl and schedule the "Fullcrawl" and "Incremental Crawl" timeframes or enable a continuous crawl.
After a successfull "Full Crawl" your document might show up in the search results.
You have that "Gear" Icon if you are on newer versions of SharePoint. If you have an older version then you can find "List Settings" or "Document Library Settings" in the ribbon of the list/library your are in.
Best Regards,
Sven
- SvenSieverdingBronze Contributor
Hi Jedrek96
I understand that you uploaded an XML file into SharePoint with the content you provided.
In that case the query http://www.test.com/_api/search/query?querytext=%27Document%27 should work. (After the file has been successfully indexed by the search crawler)
Wait an hour or so and try again....
If this still does not work then try to re-index the document library ("Gear"->"Library Settings"->"More Library Settings"->"Advanced Settings" and then scroll down to "Reindex Document Library")
If this still does not work and you are using an on Premise version of SharePoint, then ask an admin to go to "Central Administration" and check if the incremental search index is working.
The query
http://www.test.com/_api/search/query?querytext=%27title:%22Report%22%27
should only return results if you manually set the "title" property of the document to be "Report". But in that case it should work.
Best Regards,
Sven- Jedrek96Copper Contributor
Hello Sven,
Thanks for your reply. I have access to the Central Administration and these are the preset settings for the crawl (Added the images in the post above). I assume the configurations are correct based on online resources. I removed the Start Addresses for security purposes but they are right as well.
I don't seem to have the "Library Settings" under the gear icon though. Is there a workaround for this?- SvenSieverdingBronze Contributor
Hi Jedrek96 ,
It seems like that content source is not indexing anything.
You need to enable either an incremental crawl and schedule the "Fullcrawl" and "Incremental Crawl" timeframes or enable a continuous crawl.
After a successfull "Full Crawl" your document might show up in the search results.
You have that "Gear" Icon if you are on newer versions of SharePoint. If you have an older version then you can find "List Settings" or "Document Library Settings" in the ribbon of the list/library your are in.
Best Regards,
Sven