skip to Main Content

I’ve got an ACS setup with SharePoint as the datasource. It’s working well.

When I query the index and retrieve a document, I want to take that documents ID and query the sharepoint API to get additional information about that document. However, it seems that non of the identifiable information returned with the document (as documented here):

Identifier Type Description
metadata_spo_site_library_item_id Edm.String The combination key of site ID, library ID, and item ID which uniquely identifies an item in a document library for a site.
metadata_spo_site_id Edm.String The ID of the SharePoint site.
metadata_spo_library_id Edm.String The ID of document library.
metadata_spo_item_id Edm.String The ID of the (document) item in the library.
etc…

is recognised by the the sharepoint api e.g.

_api/web/lists/GetByTitle('XXXXXXXX')/items?$select=Id&$filter=Id eq '{metadata_spo_site_library_item_id}'

does not work, nor does any variation I have tried.

What am I doing wrong?

EDIT:

I am decoding the document key and keeping on the index each item it contains separately:

enter image description here

None of these provided ids identify the document in the sharepoint-api, unless I am using the wrong endpoint

2

Answers


  1. According to my research and testing, you can use the following REST API to get the SharePoint document:

    GET https://{site_url}/_api/web/lists/GetByTitle('Test')/items({item_id})
    

    More information for reference: Working with lists and list items with REST

    ————————-Update—————————

    The "item_id" is the ID column in SharePoint list/library. For example:
    enter image description here

    You can display the ID column in Lists setting ->> Edit View.

    You also can get item_id through the following REST API:

    GET https://{site_url}/_api/web/lists/GetByTitle('Test')/items
    

    Hope it can help you.

    Login or Signup to reply.
  2. By default, Azure cognitive search index key field will be encoded. So, the value will not be in readable format in search results. In this scenario, you need to add one more filed in index and map the key value to newly created filed without mapping function.
    As I have some restrictions on my access, I could not index share point data here. Instead of that I have taken a blob storage and indexed the data.
    The steps I followed are,

    1. Created index for the data source of type blob storage.
    2. Selected metadata_storage_path as key for the index.
    3. Created indexer as shown below,
    {
    
    "@odata.context": "https://searchname.search.windows.net/$metadata#indexers/$entity",
    
    "@odata.etag": ""*****"",
    
    "name": "azureblob-indexer",
    
    "description": "",
    
    "dataSourceName": "ds01",
    
    "skillsetName": null,
    
    "targetIndexName": "azureblob-index",
    
    "disabled": null,
    
    "schedule": null,
    
    "parameters": {
    
    "batchSize": null,
    
    "maxFailedItems": 0,
    
    "maxFailedItemsPerBatch": 0,
    
    "base64EncodeKeys": null,
    
    "configuration": {
    
    "dataToExtract": "contentAndMetadata",
    
    "parsingMode": "default"
    
    }
    
    },
    
    "fieldMappings": [
    
    {
    
    "sourceFieldName": "metadata_storage_path",
    
    "targetFieldName": "metadata_storage_path",
    
    "mappingFunction": {
    
    "name": "base64Encode"
    
    }
    
    },
    
    {
    
    "sourceFieldName": "metadata_storage_path",
    
    "targetFieldName": "path"
    
    }
    
    ],
    
    "outputFieldMappings": [],
    
    "cache": null,
    
    "encryptionKey": null
    
    }
    
    1. As shown in above code, I am mapping the value of metadata_storage_path to another filed path
      enter image description here
    2. Performed search on index and results are as shown below,
      enter image description here
    3. As you can see in above image, metadata_storage_path is encoded and it is not in readable format. path value is not encoded and it is in the readable format.
    4. In your scenario, I would suggest you to add a new field in index and map the new filed to it in indexer as I have done.
    5. In this way, you can query in share point Api using that new filed value.
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search