Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

123
Visualizações
cts query to select only a field from json document in Marklogic staging

I'm trying to write a javaScript cts query to query a key from a json document based on another key. i.e, similar to a query like select name from data-hub-staging where source='source1'

{
    "source": "source1",
    "name": "John",
    "DOB": "1-01-1990",
    "load_date": "2021-10-23 10:23:55"
}

I have been trying the below query but it returns all the fields, I wanted only the name field.

const query = cts.jsonPropertyValueQuery(
              "source",
              "source1");

cts.search(query)
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

The purpose of cts.search is to run a search that returns entire documents. The cts.jsonPropertyValueQuery identifies a criterion for selecting a document. After you've run the search, you'll be able to pull out whatever you'd like from that document. I think this should do it:

const query = cts.jsonPropertyValueQuery(
              "source",
              "source1");

cts.search(query)
  .toArray()
  .map(doc => doc.root.name)

You can do something similar with MarkLogic's jSearch API:

import jsearch from '/MarkLogic/jsearch.mjs';
jsearch.documents()
  .where(jsearch.byExample({source: {$value: 'source1'}}))
  .map({extract: {paths: ['/name']}})
  .result()
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda