I have for my project, this ES mapping representation :
- BOOK
- label: String,
- active: Boolean
- total_term_occ: Long
- TERMS
- label: String,
- ngram: Byte,
- tot_occurrences: Long,
- books [{
- id: String,
- label: String,
- occurrences: Long,
- tfidf: Double
}]
For each new term (ex: "ES rocks"), I want to :
- Update the total occurrence in the "TERMS" doc
OR
- Create the new term if not exists
AND (if term already exists)
- BOOK :
- Create a new object if the book does not already exist with "occurrences" to 0 and "tfidf" to NULL
OR
- Update the "occurrences" field if the book exists (with a loop ?!)
I want to make a bulk request "update -> script -> upsert" but without getting the document before updating it.
Do you think this is possible with the choice of mapping ? I can't find a good solution....
Related
I am doing a search of vendors and want to join in the Term to have the Term's name. The vendor has a field called terms which has the internalid of the Term. Term has a field called name which contains what I'm looking for.
I've tried just about every combination of building the column but I always get an error:
An nlobjSearchColumn contains an invalid column join ID, or is not in proper syntax: name.
Example of how I'm building the column:
search.createColumn({
name: "name",
join: "terms", // or Term, or Terms, none of it works
label: "termname" // or leave this out or Term or Terms or anything else nothing works
}
What is the right way to create a search for vendor that also includes the term's name?
If you'll look at the Records Browser, terms is not listed as a join on the vendor record. Just get terms as a column (name: 'terms') then when you retrieve the result, use getText instead of getValue.
searchResults[i].getText({
name: 'terms'
});
I am currently defining a parameter within my azure pipeline as follows:
parameters:
- name: nodeSize
displayName: nodeSize
type: string
default: size1
values:
- size1
- size2
The result of this, is that when attempting to run the pipeline the user is presented with a drop down menu that allows them to choose one of the defined values, as shown bellow:
My goal is to create my parameters in a way that the user can select from the dropdown box, OR enter their own value. So the resulting dropdown menu would like like:
Size 1
Size 2
<Users optional input>
I'm afraid that this is not possible. You can create two parameters:
parameters:
- name: nodeSize
displayName: nodeSize
type: string
default: size1
values:
- size1
- size2
parameters:
- name: customSize
displayName: customNodeSize
type: string
default: ' '
and then check if customSize size was provided. I understood that this is far away from perfect. But we are limited to functionality we have now.
I am very new to APIs (a week in) and I’m stuck with a challenge.
I have tables in Postgres and have created models for each. There is a link from one to another (in some circumstances). If the link doesn’t exist then I want to use a default value, held in a different table.
Example:
Table - items
- id (int)
- name (text)
- startDateTime (date)
- endDateTime (date)
Table - itemTypes
- id (int)
- name (text)
- isDefault (boolean)
Table - itemTypesLinkItems
- id (int)
- itemsId (int)
- itemTypesId (int)
- fromDateTime (date)
- toDateTime (date)
At any given date, there will be a list of items that display. Some of those might be linked to itemTypes via the itemTypesLinkItems table, and so I can show the itemTypes.Name. For the remainder, I’d like to show the itemTypes.Name value where the isDefault = true.
I’ve searched all over, tried to do it with SQL views, but no luck. I’m hoping this is something that can be done within the JavaScript of the API.
router.get(‘/:date’, (req, res) =>
db.items.findAll()({
include: [
{
model: db.itemtypelinkitem,
required: false,
include: [
{
model: db.itemtypes
}
]
where: {
startDateTime: {[Op.lte]: req.params.date},
endDateTime: {[Op.gte]: req.params.date}
}
}
]
I just don’t know where to go from here. If I exclude the ‘required’ then only those items with a link are returned. If I include it, then they all show and if there is a link it returns the details, otherwise just returns []. In the event that it returns a [], I’d like to replace that with the values from the default itemTypes.
I hope understood your question well.
You made many to many Relation between (items, itemTypes) and want to get a default
itemType when getting all items.
so I think this problem not related to Sequlize.
You have to insert default 'itemType' while inserting a new record into 'items' table.
So I'm trying to run a query on Google Cloud's datastore as such:
let query = datastore.createQuery(dataType)
.select(["id", "version", "lm", "name"])
.filter("owner", "=", request.params.owner)
.filter("lm", ">=", request.query.date_start)
.groupBy(["lm"])
.order("lm")
Yet I run into an error stating that
no matching index found. recommended index is:
- kind: Entry
properties:
- name: lm
- name: id
- name: name
- name: version
When I run the query with id instead of lm for all the methods I run into no errors.
Is this because in my index.yaml file I have the index as such: ?
- kind: Entry
properties:
- name: id
- name: version
- name: lm
- name: name
Must I actually create a new index with the recommended ordering? Or is there a way I can do this without having to make another index? Thank you!
Yes, you need to create a new index, the existing one you showed is not equivalent, so it can't be used for your query - the property order matters (at least for the inequality filters and sorting). See related Google Datastore Composite index issue
I want to do a solr search to see if a dynamic field exists or not.
Example:
Doc 1 {
Id: 111
Name: good
Tag_100_is: lsdkl
}
Doc 1 {
Id: 2
Name: not good
}
I want a query to retrieve doc 1.
Thank you in advance.
To query for whether a field exists or not, use field:[* TO *]. So in this case, you should get the document you want by using the query Tag_100_is:[* TO *].
If you want to get the document without the field, you'll have to invert the query (we start with : which are "all documents", then remove the documents that have the field):
q=*:* -Tag_100_is:[* TO *]