I am creating an index in Azure Search Service and looking for a way to allow unknown fileds to be submitted. My documents are semi structured, meaning I know few fields up front. But I want the flexibility to be able to add documents with additional fields.
for example:
{
"name":"name1",
"description":"description"
"unknown,_simple":"test",
"unknown_complex": [{
"male":20,
"female":30
}]
}
In the above example, I know about Name and Description fields so they are added to the index with correct mapping. But unknow_simple and unknown_complex types are not know. Users can submit these when they are creating the documents. Right now Azure Search Rest API is complaining with the following error message
The request is invalid. Details: parameters : A resource without a
type name was found, but no expected type was specified. To allow
entries without type information, the expected type must also be
specified when the model is specified
How can I achieve this? Thank you for you help.
Per my understanding , you want to design your index designed as semi structured , "name" and "description" are two fixed fields and with fixed data type. There will be two flexible fields that you are not sure about its data type. In fact, you can define its data type as string.
Let's say you want to store a json object in that filed, just stringizing your json object so that you can set this string value in that field. Converting this value to json when next time you need it .
If you want to query certain field of json object in your Dynamic field, you can just use the json string fragment as query key to search , just as below :
Lets assume that "Description" filed is my Dynamic field and its value is a json string , I can use the key fragment to get result I want. But it is not so elegant though .
Related
I try to get an extract of the text with the searched words highlighted on a JSON collection.
My search syntax is:
qb.word(qb.field('doc_text'),vartxt)
With 'doc_text' declared as field
(field type: root, include root: false, includes: doc_text), in an Node.js application.
The search works well, and it is done well on this field ...
But in txt[0].results[kl].matches[0]['match-text'], I find the first 3 properties of the JSON,
and not an extract from 'doc_text' with the words found.
I have another application in which the highlights work correctly, but it is based on XML.
Did I forget something in the field declaration, or is the operation different between JSON
and XML data, or is the highlight system not running on JSON via Node.js and QueryBuilder ?
Kind regards
Fields do not work quite the same way in XML and JSON. I think you're running into this limitation:
http://docs.marklogic.com/guide/app-dev/json#id_24090
The value of a field in XML can be the concatenation of all the text nodes, but the same does not apply in JSON.
I think I understood !!!
This query gives a correct snippet, with the extract and the words highlighted :
mkcq.and(mkcq.collection('document'), mkcq.word(mkcq.field('doc_text'), 'connaitre'))
On the other hand, this query gives the first 3 fields of the JSON :
mkcq.and(mkcq.collection('document'), mkcq.word(mkcq.field('doc_text'), 'connaitre'), mkcq.value(mkcq.element('','doc_user'), 'mbp'))
I do not know if this is normal or not, but it should be able to be corrected either by a simplified query and a selection on the returned records, evening by a particular snippeter.
Kind regards
I am attempted to get a Document from DocumentDB using the REST API. I am using a partitioned Collection and therefore need to add the "x-ms-documentdb-partitionkey" header. If I add this, I get "Partition key abc is invalid". I can't find anywhere in the documentation that expects the key to be in specific format, but simply supplying the expected string value does not work. Does anyone know the expected format?
Partition key must be specified as an array (with a single element). For example:
x-ms-documentdb-partitionkey: [ "abc" ]
Partition key for a partitioned collection is actually the path to a property in DocumentDB. Thus you would need to specify it in the following format:
/{path to property name} e.g. /department
From Partitioning and scaling in Azure DocumentDB:
You must pick a JSON property name that has a wide range of values and
is likely to have evenly distributed access patterns. The partition
key is specified as a JSON path, e.g. /department represents the
property department.
More examples are listed in the link as well.
I am writing a webscript, wherein I have a custom content model.
I want to list all the documents, that have a particular property as one of it's attributes.
Firstly I did
search.luceneSearch("PATH:\"/app:company_home//*\" AND #cm:name:myDocument")
This returned me value 1. But this query actually returns me the documents, whose cm:name property is myDocument.
what if I want to search for documents, who has cm:name property as an attribute.
So that later, I can change cm:name with mycontentmodel:myproperty, and find the elements that belong to my content type.
If I understand correctly, you'd like to find all the documents that have property mycontentmodel:myproperty, but you're not interested in the actual value of the property.
If so, find out what type or aspect mycontentmodel:myproperty belongs to.
If it belongs to type mycontentmodel:mytype the query can be:
PATH:"/app:company_home//*" AND TYPE:"mycontentmodel:mytype"
and if it belongs to aspect mycontentmodel:myaspect
PATH:"/app:company_home//*" AND ASPECT:"mycontentmodel:myaspect"
How to find particular json document details from couchdb
For ex : Database name : employee_mgmt, in that database contains 50 json documents. So i want to find particular employee json documents ( Find by employee id ).
CouchDB does in it self not provide you with collections/buckets, hence all your documents are peers. It's up to you to provide meta-data e.g. by having a property $doctype with a value representing what kind of document it is. This is useful if you are writing maps and e.g. want to create a view (secondary index) returning something applicable only to employees.
Know, if you just want to query by _id you don't need the above. Just do a simple GET with an URI as: http://host:port/databasename/documentid
More information: http://docs.couchdb.org/en/1.6.1/api/document/common.html#get--db-docid
If you want to get a batch of documents matching many _id use the builtin index _all_docs http://docs.couchdb.org/en/1.6.1/api/database/bulk-api.html#post--db-_all_docs
Is this possible to set or override the internalid of a custom record type ?
The internalid is self generated, but I want to try to set inernalid value from a cvs field.
I do not believe you can override the internalid of any record instance, even a custom one. You can, however, use the externalid field that I believe every record has if you want to specify a "secondary" identifier for the record.
You cannot override the internal ID of a record. As mentioned in a previous response to your question, you can (and should) set the external ID field on the NetSuite records to equal the primary key of the data being imported.
On future imports that update NetSuite data, you simply map the key field of the imported data to the external ID field in NetSuite. You can ignore the internal ID field on those future imports, as Netsuite will match up the records based upon the external ID.
This is the proper way to do this - I've seen tons of situations where people did not understand the external ID concept, and created huge, long term maintenance issues by not following this simple solution.
OK. Given your feedback, why not create another custom field on the customer record that references the lookup value in the custom record?
The field type should be the same as the field type of the lookup value, with "store value" checkbox unchecked. On the Sourcing and Filtering tab, you specify the custom record type and field to reference. Think of it as a SQL join of sorts between the customer record and custom record.
Then, you should be able to do what you want with 2 getCurrentAttribute tags:
<%= getcurrentattribute('cusomter', 'custentity_mappingid')%>
<%= getcurrentattribute('cusomter', 'custentity_mappingvalue')%>
BTW, your custom field internal IDs look a little odd. They should start with 'custentity', and 'custrecord', respectively. My code above reflects what you'd normally expect from NetSuite.
You can set ExternalId and if you want to get record then you can use callGetRecordByExternalId .
public ReadResponse callGetRecordByExternalId(String externalId, RecordType recordType) throws RemoteException {
return this.callGetRecord(Utils.createRecordRefWithExternalId(externalId, recordType));
}