cancel
Showing results for 
Search instead for 
Did you mean: 

Search API result gives empty entities

FrankyDee
Champ on-the-rise
Champ on-the-rise

Hi there,

I'm new to Alfresco development so please, bare  with me.

I post the following body to the search api (using postman)

{
	"query": {
		"language": "afts",
		"userQuery": null,
		"query": "+TYPE:\"cm:content\" AND content.mimetype:\"image/vnd.dwg\" AND ANCESTOR:\"workspace://SpacesStore/7e369873-7b19-4d0d-bc8e-fab2b50ca641\""
	},
	"paging": {
		"maxItems": 25,
		"skipCount": 0
	},
	"include": null,
	"includeRequest": false,
	"fields": [
		"cm:description",
		"cm:title",
		"cm:versionLabel"
	],
	"sort": [
		{
			"type": "FIELD",
			"field": "cm:name",
			"ascending": true
		}
	],
	"templates": null,
	"defaults": null,
	"localization": {
		"timezone": null,
		"locales": [
			"en-US"
		]
	},
	"filterQueries": null,
	"facetQueries": null,
	"facetFields": null,
	"facetIntervals": null,
	"pivots": null,
	"stats": null,
	"spellcheck": null,
	"scope": null,
	"limits": null,
	"highlight": null,
	"ranges": null
}

and I get

{
    "list": {
        "pagination": {
            "count": 4,
            "hasMoreItems": false,
            "totalItems": 4,
            "skipCount": 0,
            "maxItems": 25
        },
        "context": {
            "consistency": {
                "lastTxId": 348
            }
        },
        "entries": [
            {
                "entry": {}
            },
            {
                "entry": {}
            },
            {
                "entry": {}
            },
            {
                "entry": {}
            }
        ]
    }
}

As you can see, I get empty entries.

Now, if I remove the fields frommy qury, then I get the result expected.

However, I need to get those properties in the result.

Any idea?

1 ACCEPTED ANSWER

Forget it, I found the solution.

In stead of defineing the fields, I just needed to include the properties. The right query body would now look like 

{
	"query": {
		"language": "afts",
		"userQuery": null,
		"query": "+TYPE:\"cm:content\" AND content.mimetype:\"image/vnd.dwg\" AND ANCESTOR:\"workspace://SpacesStore/7e369873-7b19-4d0d-bc8e-fab2b50ca641\""
	},
	"paging": {
		"maxItems": 25,
		"skipCount": 0
	},
	"include": [
		"properties"
	],
	"includeRequest": false,
	"fields": null,
	"sort": [
		{
			"type": "FIELD",
			"field": "cm:name",
			"ascending": true
		}
	],
	"templates": null,
	"defaults": null,
	"localization": {
		"timezone": null,
		"locales": [
			"en-US"
		]
	},
	"filterQueries": null,
	"facetQueries": null,
	"facetFields": null,
	"facetIntervals": null,
	"pivots": null,
	"stats": null,
	"spellcheck": null,
	"scope": null,
	"limits": null,
	"highlight": null,
	"ranges": null
}

View answer in original post

2 REPLIES 2

FrankyDee
Champ on-the-rise
Champ on-the-rise

I forgot to mention that I'm using the Community edition version 7.2 is that can make a difference....

Forget it, I found the solution.

In stead of defineing the fields, I just needed to include the properties. The right query body would now look like 

{
	"query": {
		"language": "afts",
		"userQuery": null,
		"query": "+TYPE:\"cm:content\" AND content.mimetype:\"image/vnd.dwg\" AND ANCESTOR:\"workspace://SpacesStore/7e369873-7b19-4d0d-bc8e-fab2b50ca641\""
	},
	"paging": {
		"maxItems": 25,
		"skipCount": 0
	},
	"include": [
		"properties"
	],
	"includeRequest": false,
	"fields": null,
	"sort": [
		{
			"type": "FIELD",
			"field": "cm:name",
			"ascending": true
		}
	],
	"templates": null,
	"defaults": null,
	"localization": {
		"timezone": null,
		"locales": [
			"en-US"
		]
	},
	"filterQueries": null,
	"facetQueries": null,
	"facetFields": null,
	"facetIntervals": null,
	"pivots": null,
	"stats": null,
	"spellcheck": null,
	"scope": null,
	"limits": null,
	"highlight": null,
	"ranges": null
}