Expand my Community achievements bar.

SOLVED

AEM Querybuilder API: Unable to fetch path?

Avatar

Level 5

I want to fetch path of a given node only and here's my query:

type=nt:unstructured
path=/content/dam/wknd-shared/en/adventures
nodename=master
p.hits=selective
p.properties=tripLength path

 

However this is what I get:

{
  "success": true,
  "results": 10,
  "total": 16,
  "more": false,
  "offset": 0,
  "hits": [
    {
      "tripLength": "3 Days"
    },
    {
      "tripLength": "5 Days"
    },
    {
      "tripLength": "1 Day"
    },
    {
      "tripLength": "3 Days"
    },
    {
      "tripLength": "5 Days"
    },
    {
      "tripLength": "2 Days"
    },
    {
      "tripLength": "4 Days"
    },
    {
      "tripLength": "1 Day"
    },
    {
      "tripLength": "2 Days"
    },
    {
      "tripLength": "3-4 days"
    }
  ]
}

Can someone help me identify how to get the path and tripLength both?

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hi @spidey1405,

If by path you mean path to each node that is included in result you can use jcr:path as a property, so your query will look like this:

type=nt:unstructured
path=/content/dam/wknd-shared/en/adventures
nodename=master
p.hits=selective
p.properties=tripLength jcr:path

and the results:

{
    "success": true,
    "results": 10,
    "total": 16,
    "more": false,
    "offset": 0,
    "hits": [
        {
            "tripLength": "3 Days",
            "jcr:path": "/content/dam/wknd-shared/en/adventures/riverside-camping-australia/riverside-camping-australia/jcr:content/data/master"
        },
        {
            "tripLength": "5 Days",
            "jcr:path": "/content/dam/wknd-shared/en/adventures/ski-touring-mont-blanc/ski-touring-mont-blanc/jcr:content/data/master"
        },
        {
            "tripLength": "1 Day",
            "jcr:path": "/content/dam/wknd-shared/en/adventures/napa-wine-tasting/napa-wine-tasting/jcr:content/data/master"
        },
        {
            "tripLength": "3 Days",
            "jcr:path": "/content/dam/wknd-shared/en/adventures/colorado-rock-climbing/colorado-rock-climbing/jcr:content/data/master"
        },
        {
            "tripLength": "5 Days",
            "jcr:path": "/content/dam/wknd-shared/en/adventures/surf-camp-in-costa-rica/surf-camp-costa-rica/jcr:content/data/master"
        },
        {
            "tripLength": "2 Days",
            "jcr:path": "/content/dam/wknd-shared/en/adventures/whistler-mountain-biking/whistler-mountain-biking/jcr:content/data/master"
        },
        {
            "tripLength": "4 Days",
            "jcr:path": "/content/dam/wknd-shared/en/adventures/cycling-tuscany/cycling-tuscany/jcr:content/data/master"
        },
        {
            "tripLength": "1 Day",
            "jcr:path": "/content/dam/wknd-shared/en/adventures/gastronomic-marais-tour/gastronomic-marais-tour/jcr:content/data/master"
        },
        {
            "tripLength": "2 Days",
            "jcr:path": "/content/dam/wknd-shared/en/adventures/climbing-new-zealand/climbing-new-zealand/jcr:content/data/master"
        },
        {
            "tripLength": "3-4 days",
            "jcr:path": "/content/dam/wknd-shared/en/adventures/tahoe-skiing/tahoe-skiing/jcr:content/data/master"
        }
    ]
}

View solution in original post

2 Replies

Avatar

Correct answer by
Community Advisor

Hi @spidey1405,

If by path you mean path to each node that is included in result you can use jcr:path as a property, so your query will look like this:

type=nt:unstructured
path=/content/dam/wknd-shared/en/adventures
nodename=master
p.hits=selective
p.properties=tripLength jcr:path

and the results:

{
    "success": true,
    "results": 10,
    "total": 16,
    "more": false,
    "offset": 0,
    "hits": [
        {
            "tripLength": "3 Days",
            "jcr:path": "/content/dam/wknd-shared/en/adventures/riverside-camping-australia/riverside-camping-australia/jcr:content/data/master"
        },
        {
            "tripLength": "5 Days",
            "jcr:path": "/content/dam/wknd-shared/en/adventures/ski-touring-mont-blanc/ski-touring-mont-blanc/jcr:content/data/master"
        },
        {
            "tripLength": "1 Day",
            "jcr:path": "/content/dam/wknd-shared/en/adventures/napa-wine-tasting/napa-wine-tasting/jcr:content/data/master"
        },
        {
            "tripLength": "3 Days",
            "jcr:path": "/content/dam/wknd-shared/en/adventures/colorado-rock-climbing/colorado-rock-climbing/jcr:content/data/master"
        },
        {
            "tripLength": "5 Days",
            "jcr:path": "/content/dam/wknd-shared/en/adventures/surf-camp-in-costa-rica/surf-camp-costa-rica/jcr:content/data/master"
        },
        {
            "tripLength": "2 Days",
            "jcr:path": "/content/dam/wknd-shared/en/adventures/whistler-mountain-biking/whistler-mountain-biking/jcr:content/data/master"
        },
        {
            "tripLength": "4 Days",
            "jcr:path": "/content/dam/wknd-shared/en/adventures/cycling-tuscany/cycling-tuscany/jcr:content/data/master"
        },
        {
            "tripLength": "1 Day",
            "jcr:path": "/content/dam/wknd-shared/en/adventures/gastronomic-marais-tour/gastronomic-marais-tour/jcr:content/data/master"
        },
        {
            "tripLength": "2 Days",
            "jcr:path": "/content/dam/wknd-shared/en/adventures/climbing-new-zealand/climbing-new-zealand/jcr:content/data/master"
        },
        {
            "tripLength": "3-4 days",
            "jcr:path": "/content/dam/wknd-shared/en/adventures/tahoe-skiing/tahoe-skiing/jcr:content/data/master"
        }
    ]
}