2

We are having issues indexing metadata with items added to Google Cloud Search with 3rd-party datasources, using the REST API. We are following this guide: https://developers.google.com/cloud-search/docs/guides/schema-guide.

What we tried: uploaded the schema successfully ✅, indexed some items ✅, made them available in the search UI ✅, but it seems the properties and facets not showing up whether it’s in the green metadata bits in search results or in API results -- we get an empty structuredData object. Search results seem to only query the content.inlineContent and nothing else. We’re not getting any errors from the API when we make the index request (using https://developers.google.com/cloud-search/docs/reference/rest/v1/indexing.datasources.items/index_). It seems like it’s just ignoring everything in structuredData.

Other attempts: In addition to the REST API, we’ve also used the official nodejs SDK, (which has additional validation because it’s in TypeScript), to no avail. We’ve verified that auth params are correct (it returns 401 otherwise) and that there are no other validation issues (it returns 400 otherwise). Requests return 200 and do upload successfully, just not the structuredData. The original schema upload was also successful (200), and the response included the full schema we gave.

What are we missing?

schema JSON:

{
    "objectDefinitions": [{
        "name": "page",
        "options": {
            "displayOptions": {
                "objectDisplayLabel": "Page",
                "metalines": [
                    {
                        "properties": [
                            {
                                "propertyName": "title"
                            },
                            {
                                "propertyName": "content"
                            },
                            {
                                "propertyName": "author"
                            },
                            {
                                "propertyName": "siteSection"
                            }
                        ]
                    }
                ]
            }
        },
        "propertyDefinitions": [
            {
                "name": "title",
                "isReturnable": true,
                "isWildcardSearchable": true,
                "isSuggestable": true,
                "isRepeatable": false,
                "isFacetable": false,
                "textPropertyOptions": {
                    "operatorOptions": {
                        "operatorName": "title"
                    }
                },
                "displayOptions": {
                    "displayLabel": "Title"
                }
            },
            {
                "name": "content",
                "isReturnable": true,
                "isRepeatable": false,
                "isFacetable": false,
                "htmlPropertyOptions": {
                    "retrievalImportance": {
                        "importance": "DEFAULT"
                    }
                },
                "displayOptions": {
                    "displayLabel": "Content"
                }
            },
            {
                "name": "author",
                "isReturnable": true,
                "isRepeatable": true,
                "isFacetable": true,
                "textPropertyOptions": {
                    "operatorOptions": {
                        "operatorName": "author"
                    }
                },
                "displayOptions": {
                    "displayLabel": "Author(s)"
                }
            },
            {
                "name": "siteSection",
                "isReturnable": true,
                "isWildcardSearchable": false,
                "isSuggestable": false,
                "isRepeatable": false,
                "isFacetable": true,
                "textPropertyOptions": {
                    "operatorOptions": {
                        "operatorName": "sitesection"
                    }
                },
                "displayOptions": {
                    "displayLabel": "Site Section"
                }
            }
        ]
    }]
}

indexing code:

const version = '4';
const apiUrl = `https://cloudsearch.googleapis.com/v1/indexing/datasources/${sourceId}/items/exampleItem:index`;
const title = "Example Item";
const url = "https://example.com";

fetch(apiUrl, {
    method: "POST",
    headers: {
        "Content-Type": "application/json",
        Authorization: "Bearer " + token,
    },
    body: JSON.stringify({
        item: {
            name: `datasource/${sourceId}/items/exampleItem`,
            acl: {
                readers: [
                    {
                        gsuitePrincipal: {
                            gsuiteDomain: true,
                        },
                    },
                ],
            },
            metadata: {
                title: title,
                sourceRepositoryUrl: url,
                objectType: "page",
            },
            structuredData: {
                object: {
                    properties: [
                        {
                            name: "title",
                            textValues: {
                                values: [title],
                            },
                        },
                        {
                            name: "author",
                            textValues: {
                                values: ["Unknown Author"],
                            },
                        },
                        {
                            name: "siteSection",
                            textValues: {
                                values: ["exampleSection"],
                            },
                        },
                        {
                            name: "content",
                            htmlValues: {
                                values: [exampleContentHTML],
                            },
                        },
                    ],
                },
            },
            content: {
                inlineContent: b64(exampleContentHTML),
                contentFormat: "TEXT",
            },
            version: b64(version),
            itemType: "CONTENT_ITEM",
        },
        mode: "SYNCHRONOUS",
    }),
})

indexing result:

{
    "name": "datasources/DATASOURCE_ID/items/exampleItem",
    "acl": {
        "readers": [{
            "gsuitePrincipal": {
                "gsuiteDomain": true
            }
        }]
    },
    "metadata": {
        "title": "Example Item",
        "sourceRepositoryUrl": "https://example.com",
        "objectType": "page"
    },
    "structuredData": {
        "object": {}
    },
    "content": {
        "inlineContent": "... base 64 encoded content...",
        "contentFormat": "TEXT"
    },
    "version": "NQ==",
    "status": {
        "code": "ACCEPTED"
    },
    "queue": "default",
    "itemType": "CONTENT_ITEM"
}

Max
  • 23
  • 6

0 Answers0