swat
swat

Reputation: 81

Marklogic snippet return incomplete result set

I am looking out method for getting all matches in snippet.but I am getting incomplete set of result. I have set maxSnippetChars,maxMatches,perMatchTokens values to max. Structure of documents is an array of objects and I want path all matching object's property(Synopsis) which satisfy matching criteria. can you please help me out. I am using below code:-

.where(jsearch.byExample({"$query":{Synopsis:{"$word":"word","$case-sensitive":false}}}))
.slice(0, Number.MAX_SAFE_INTEGER)
 .map({
   snippet: {

   maxSnippetChars:Number.MAX_SAFE_INTEGER,
     maxMatches:Number.MAX_SAFE_INTEGER,
   perMatchTokens: Number.MAX_SAFE_INTEGER
  }, extract: {paths: ['/ID','/FullName']}
  } 
  )
 .result() ```

Upvotes: 0

Views: 61

Answers (1)

Fiona Chen
Fiona Chen

Reputation: 1368

If your intention is to configure the snippet generator properties, you can adjust the build-in mapper order in the jsearch pipeline as below:

  .where(jsearch.byExample({synopsis: {$word: 'word'}}))
  .slice(0, 15)
  .map({extract: {paths: ['/ID','/FullName']}},
      {snippet: {
        maxSnippetChars: 150,
        maxMatches: 4,
        perMatchTokens: 30
  }})
  .result()
  • Notice the logic is to extract the xpath properties first then apply the build-in snippet generator.
  • The caveat of using the blanket ***_INTEGER: Doing so may return fewer match snippet text by setting it too small or negate the constraint by setting it too big.

Generally speaking, below query should return the desired extracted paths and snippet without losing any text:

  .where(jsearch.byExample({synopsis: {$word: 'word'}}))
  .slice(0, 15)
  .map({extract: {paths: ['/ID','/FullName']}}
  .result()

Upvotes: 1

Related Questions