AEM Querybuilder API: Unable to fetch path? | Community
Skip to main content
September 19, 2022
Solved

AEM Querybuilder API: Unable to fetch path?

  • September 19, 2022
  • 1 reply
  • 779 views

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?

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by lukasz-m

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"
        }
    ]
}

1 reply

lukasz-m
Community Advisor
lukasz-mCommunity AdvisorAccepted solution
Community Advisor
September 19, 2022

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"
        }
    ]
}
September 19, 2022

thank you very very much @lukasz-m this is exactly what I needed!