Getting text from results of search

SearchRequest returns a response with NodeIds:

[
{"range_start":{"Node":{"NodeId":"0.0.4.0"},"Offset":0},"range_end":{"Node":{"NodeId":"0.0.4.0"},"Offset":13}},
{"range_start":{"Node":{"NodeId":"0.0.8.1"},"Offset":5},"range_end":{"Node":{"NodeId":"0.0.8.3"},"Offset":13}}
]

How can I extract the actual text found? I’ve been using getRangeText but I don’t see how to use the NodeIds in conjunction with the offsets to get the desired text.

@FFSPUD

You need to pass the starting node ID and ending node ID of the range to get the text of the specified range. Please check the following cURL command. To get the text of the second paragraph, we will pass the second paragraph node id as rangeStartIdentifier and the third paragraph node id as rangeEndIdentifier. Hopefully, it will help you accomplish the task.

curl -v "https://api.aspose.cloud/v4.0/words/online/get/range/id0.0.1/id0.0.2" -X PUT -H "Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR.....kspXpA5-H_6qKqWDYujlLwA" -H "Content-Type: multipart/form-data" -F Document="@02_pages.docx" 

Response:

“Text”:
"How to fold origami candy boxes ",

Hi Tilal.

Thanks for your quick response.

I understand that I need to pass in the start and and end node. What I don’t understand is how to use the data returned by the call to Search to do this.

If I have some text:

find me
Text before find me
find me text after
Before find me text find me after

and I search for ‘find me’, I get these nodes:

[
{"range_start":{"Node":{"NodeId":"0.0.0.0"},"Offset":0},"range_end":{"Node":{"NodeId":"0.0.0.0"},"Offset":7}},
{"range_start":{"Node":{"NodeId":"0.0.1.1"},"Offset":0},"range_end":{"Node":{"NodeId":"0.0.1.1"},"Offset":7}},
{"range_start":{"Node":{"NodeId":"0.0.2.0"},"Offset":0},"range_end":{"Node":{"NodeId":"0.0.2.0"},"Offset":7}},
{"range_start":{"Node":{"NodeId":"0.0.3.1"},"Offset":0},"range_end":{"Node":{"NodeId":"0.0.3.1"},"Offset":7}},
{"range_start":{"Node":{"NodeId":"0.0.3.1"},"Offset":13},"range_end":{"Node":{"NodeId":"0.0.3.2"},"Offset":20}}
]

If I then call getRangeText using these range_start and range_end nodes I get:

[
"",
"",
"",
"",
"find me text find m"
]

How do I pass in the correct NodeIds to extract just the ‘find me’ text?

@FFSPUD

Thanks for sharing additional information. We have logged a ticket(WORDSCLOUD-2526) for further investigation. We will keep you updated on the issue resolution in this forum thread.

Sorry for the late response. To achieve your requirements, you need to specify the end attribute for the randeEndIdentifier because, by default, range operations take everything before rangeEndIdentifier; when you add end, it means you included the end node to the range.
In the scenario you posted, the start node will be id0.0.1.4, and the end node will be id0.0.1.6:end.

The issues you have found earlier (filed as WORDSCLOUD-2526) have been fixed in this update. This message was posted using Bugs notification tool by Ivanov_John