To add a list of Strings to Lucene document - string

Suppose I've a field which is a List (Say : "Key" : ["value1", "value2", "value3"]. How do add it to a lucene document in a sequence map. I'm currently loading the content from a file in a sequence and mapping each entry to a document and for each entry adding the document using index writer.
seq(items)
.map(item -> {
Document document = new Document();
document.add(new TextField("field", item.field(), Field.Store.YES));
return document;
})
.forEach(consumer(indexWriter::addDocument));
I'm not struggling to add a field which is a list of strings to the above index document. Can someone please help ?

You don't need to create a document per value in that field but conversely, using the same document you just use document.add(<field>) for each value of the list (provided that field is defined as multivalued) :
Document document = new Document();
seq(items).map(item -> {
document.add(new TextField('field', item.field(), Field.Store.YES));
});
yourIndexWriter.addDocument(document);

Related

Get SharePoint item from document library based on custom metadata

I am storing metadata with my documents and folders in SharePoint. This metadata includes an itemid which is a unique identifier from the system it came from. Is there a way to retrieve the item from SharePoint using Graph API by specifying the itemid in the metadata?
This query works for properties that Microsoft provides like name:
https://graph.microsoft.com/v1.0/sites/{siteid}/drive/root/children?$filter=name eq 'Z'
But if I try it with the custom property then I simply get an empty result:
https://graph.microsoft.com/v1.0/sites/{siteid}/drive/root/children?$filter=itemid eq 'Z'
Is there a way to query documents and folders with custom properties like this?
Here is the code used to update the field on the document in SharePoint using Graph API:
public FieldValueSet UpdateListItem(string siteId, string driveId, string fileItemId, Dictionary<string, object> additionalData)
{
var updateFileTagsRequest = graphClient.Sites[siteId].Drives[driveId].Items[fileItemId].ListItem.Fields.Request();
var fieldValueSet = new FieldValueSet { AdditionalData = additionalData };
var result = updateFileTagsRequest.UpdateAsync(fieldValueSet).Result;
return result;
}
The dictionary values being passed to the UpdateListItem method are strings and look like this: "ItemId", "A unique value"

ravendb NodeJS, load related document and create a nested result in a query

I have an index that returns something like this
Company_All {
name : string;
id : string;
agentDocumentId : string
}
is it possible to load the related agent document and then generate a nested result with selectFields and QueryData like this
ICompanyView {
companyName : 'Warner',
user {
documentId : 'A/1'
firstName : 'john',
lastName : 'paul'
}
}
I need something like the below query that obviously doesn't work as I expect:
const queryData = new QueryData(
["name", "agentDocumentId", "agent.firstName", "agent.lastName"],
["companyName", "user.documentId", "user.lastName", "user.firstName"]);
return await session.query<Company_AllResult>({ index: Company_All })
.whereEquals("companyId", request.companyId)
.include(`agents/${agentDocumentId}`) // ????
.selectFields(queryData,ICompanyView)
.single();
Yes, you can do that using:
https://ravendb.net/docs/article-page/5.4/nodejs/indexes/indexing-related-documents
This is called indexing related documents, and is accessible at indexing time, not query time.
Alternatively, you have the filter clause, which has access to the loaded document, but I wouldn't generally recommend doing this.
Generally:
When you query an index, the results of querying the index are the documents from the collection the index was defined on.
Index-fields defined in the index are used to filter the index-query
but the results are still documents from the original collection.
If you define an index that indexes content from a related-document then when making an index-query you can filter the documents by the indexed-fields from the related documents, but the results are still documents from the original collection.
When making an index-query (or any other query) you can project the query results so that Not the full documents of the original collection are returned but some other object.
Now:
To project/get data from the indexed related-document you have 2 options:
Store the index-fields from the related-document in the index.
(Store all -or- specific fields).
This way you have access to that content when making a projection in your query.
See this code sample.
Don't store the index-fields from the related-document,
then you will be able to use the index-fields to filter by in your query,
but to get content you will need to use 'include' feature in your query,
and then use the session.load, which will Not make another trip to the server.
i.e. https://demo.ravendb.net/demos/nodejs/related-documents/query-related-documents

Send envelope - replacing multiple template documents

I have a question regarding the following scenario.
I have a Docusign template with 2 documents. Template contains two Template Roles with few signature tags applied on documents. There could be also Text Input tags, checkbox tags etc...
What I need is to send an envelope with documents that will replace both template documents but to apply DocuSign tags (signature, checkbox..) that were configured in the template, to apply document visibility, and as much DS template features as it can.
Signature request (envelope) is sent using DocuSign.eSign C# client library.
I'm using following code that builds Composite Template that contains two new documents with appropriate documentIDs retrieved from DocuSign template.
EnvelopeDefinition envDef = new EnvelopeDefinition();
envDef.EmailSubject = "Subject";
envDef.EmailBlurb = "Body";
envDef.CompositeTemplates = new List<CompositeTemplate>();
envDef.CompositeTemplates.Add(new CompositeTemplate
{
ServerTemplates = new List<ServerTemplate> {
new ServerTemplate
{
Sequence = "2",
TemplateId = "TEMPLATE_ID_GOES_HERE"
}
},
InlineTemplates = new List<InlineTemplate>
{
new InlineTemplate
{
Sequence = "1",
Documents = new List<DocuSign.eSign.Model.Document>
{
new Document
{
DocumentBase64 = "...", //document content
Name ="some.pdf",
DocumentId = "TEMPLATE_DOC1_ID_GOES_HERE" //ID of template document that should be replaced
},
new Document
{
DocumentBase64 = "...", //document content
Name ="another.pdf",
DocumentId = "TEMPLATE_DOC2_ID_GOES_HERE" //ID of template document that should to be replaced
}
}
}
}
});
Envelope is successfully sent, signers can see both new documents, but there are no Tags that were configured in the Template (on Docusign Web UI), and I'd like to avoid sending recipient tabs from client.
Am I missing something?
Thanks.
Change the sequencing order so the new documents are listed first.
With composite templates, order matters. For documents, the earlier documents are used. -- So your new documents should be before the server template (and its documents).
For everything else, the later information wins.
See this answer: https://stackoverflow.com/a/44376770/64904
On second thought, I see that you're doing this and it is all working except that the tabs are not being applied to the new documents.
Try the merge_roles_on_draft query parameter. Also, if you're using anchor tabs, add the applyAnchorTabs: 'true' element to the document objects.

Query documents in an array in mongodb using node.js

How to query all documents present inside an Array which itself is present in a MongoDB collection under Node.js.
For example: I have a DB with a structure:
{
"name1":[{"height":"5.5"},
{"weight":"57"}],
"name2":[{"height":"6.1"},
{"weight":"74"}]
}
What query should I make to get all the documents( i.e. height, weight) of the array "name1"
Output should be :
{
{ "height":"5.5"}
{"weight":"57"}
}
My suggestion would be to reorganise the collection so each document has a key of name and key of physicalattributes e.g.
{
'name' : 'name1',
'physAttr': ['height': heightvalue,
'weight': weightvalue]
}
then suppose you wanted to find all documents with height 5.5, the query would be trivial
db.collection.find({ 'physAttr.height': 5.5 })
As described in the question each document in the collection has a different schema from the others (different name key for every document) making query operations difficult.

CouchDb view - key in a list

I Want to query CouchDB and I have a specific need : my query should return the name field of documents corresponding to this condition : the id is equal or contained in a document filed (a list).
For example, the field output is the following :
"output": [
"doc_s100",
"doc_s101",
"doc_s102",
"doc_s103",
],
I want to get all the documents having in their output field "doc_s102" for example.
I wrote a view in a design document :
"backward_by_docid": {
"map": "function(doc) {if(doc.output) emit(doc.output, doc.name)}"
}
but this view works only when I have a unique value in the output field.
How can I resolve this query ?
Thanks !
you have to iterate over the array:
if(doc.output) {
for (var curOutput in doc.output) {
emit (doc.output[curOutput],doc.name);
}
}
make sure that output always is an array (at least [])
.. and, of course use key="xx" instead key=["xxx"]

Resources