I can get a searched document as following golang code:
ret, err := client.Query(f.Get(f.MatchTerm(f.Index("label_search_by_externalID"), externalID)))
Then, I tried to delete a searched document as similar manner as follow:
ret, err := client.Query(f.Delete(f.MatchTerm(f.Index("label_search_by_externalID"), externalID)))
But, this code occurs an error:
Response error 400. Errors: [delete](invalid argument): Ref expected, Set provided.
I'm confused, by the API document, both Get and Delete request Ref for a document as param, and MatchTerm returns a Set, not Ref. Then I have 2 questions.
ret, err := client.Query(f.Delete(f.RefIndex(f.Index("label_search_by_externalID"), externalID)))
Thank you for your suggestion!
Get will only return 1 result. If you have multiple values returned from this index search you will have problems. I would suggest the function Paginate(). This will return a set of results, which you can then map over and execute other functionality, such as a get() or delete(). I would strong suggest you look at the following tutorial (https://docs.fauna.com/fauna/current/tutorials/indexes/pagination).
This is pseudo code to delete a page of documents found. You can adjust the page size either up or down:
Map(
Paginate(Match(Index("label_search_by_externalID"), true)),
Lambda("X", Delete(Var("X")))
)