Can i reference in Criterion some Extended Attribute from another Powerdesigner XEM? - customization

Let's say i have two Extensions attached to some Powerdesigner model:
xem_a
xem_b.
In xem_a is Extended Attribute ea_a and in xem_b is Extended Attribute ea_b. In xem_a i can create Criterion with condition:
%ea_a%==true
, but i want to create Criterion in xem_a referencing Extended Attribute ea_b from xem_b. I tried:
%xem_b.ea_b%==true
and some similar expressions but without success. Is it even possible to reference Extended Attribute from another XEM in Criterion?

In order to retrieve the value of extended attributes coming from other extensions, you have to prefix with .D:
%.D:ea_b%
I didn't know it, I found it in the online docs.

Related

DynamoDB ProjectionExpression exclude attribute (all fields except one)

I have a requirement where my dynamodb table has many attributes, and i need all of them in the projection expression except one or two columns which i dont need in response. (I am scanning the table).
Is there a way how can i define this in ProjectionExpression (all except this one column).
I have seen examples where ProjectionExpression only takes what all "is required" and not the other way.
As per the documentation, this is not possible:
ProjectionExpression - A string that identifies one or more attributes
to retrieve from the table. These attributes can include scalars,
sets, or elements of a JSON document. The attributes in the expression
must be separated by commas. If no attribute names are specified, then
all attributes will be returned.
Here is a link to help you better undestand what goes underneath the ProjectionExpression: https://medium.com/pageup-tech/dynamodb-and-projection-expressions-why-c08c40243195

Is it possible to query multiple AWS Cloudsearch fields for the same value without repeating?

Using AWS Cloudsearch, I need to query 2 separate fields for the same value using a structured (compound) query e.g.
(and (or name:'john smith') (or curr_addr:'123 someplace' other_addr:'123 someplace'))
This query works, but I'm wondering if it's necessary to repeat the value for each field that I want to search against. Is there some way to specify the value only once e.g. curr_addr+other_addr:'123 someplace'
That is the correct way to structure your compound query. From the AWS documentation, you'll see that they structure their example query the same way:
(and title:'star' (or actors:'Harrison Ford' actors:'William Shatner')(not actors:'Zachary Quinto'))
From Constructing Compound Queries
You may be able to get around this by listing the more repetitive fields in the query options (q.options), and then specify the field for the rest of the fields. The fields list is sort of a fallback for when you don't specify which field you are searching in a compound query. So if you list the address fields there, and then only specify the name field in your query, you may get close to the behavior you're looking for.
Query options
q.options={fields: ['curr_addr','other_addr']}
Query
(and (or name:'john smith') (or '123 someplace'))
But this approach would only work for one set of repetitive fields, so it's not a silver bullet by any means.
From Search API Reference (see q.options => fields)

Weka GUI: add attribute is-missing-value

I have a couple of attributes with missing values.
This is a survey, so the fact that the person refused to answer is, by itself, useful information!
I would like to create a new attribute called is-missing-value = 1 if a given value in an attribute is a missing value and 0 otherwise.
Things I have tried:
I have tried using AddExpression, but this seems to only perform arithmetic operations such as 2*attribute.
I know that MathExpression allows using if-elses, such as ifelse(A < 3.0, 1, 0)... Do you guys know if/how I can test if a value is nan?
MakeIndicator (or NominalToBinary) should be able to do what I want, but I think I need (i) to convert my missing values to a nominal value, so that then (ii) I can convert this new nominal value to binary. The problem is that ReplaceMissingValue only works for mode or mean; I need to be able to define a new value. One solution could be to Edit the data directly, but I'd rather avoid this.
Please notice that I need to do this using the Weka GUI, not the Java interface.
I think I have a solution for you:
copy the attribute (if you want the original one to remain): apply the copy filter (this and the following filters are all under unsupervised/attribute folder) with the index of the attribute
Convert your attribute to nominal using the numericToNominal filter (set the attribute index)
Fill the missing values with a new value using ReplaceMissingWithUserConstant. Here you need to specify the nominalStringReplacementValue parameter (e.g. "missing") in addition to the index of your attribute.
Apply the NominalToBinary filter on your attribute. This will create several new attributes (as the number of unique values in the dataset + the missing value). You can remove the attributes you don't need and keep only the missing attribute.
Hope it helped.

Drupal 8: Altering Search API queries

I'm working on a project which includes the following activated modules:
Drupal core 8.2.3
Database Search 8.x-1.0-beta4
Search API 8.x-1.0-beta4
Search API Term Handlers 8.x-1.0-beta4
Views 8.2.3
I have a list of nids which need to be excluded from the search result of the site-wide search. The search uses Search API and has been setup using Views.
The table in the database is: "search_api_db_default_index"
The field I wish to target is: "nid"
I wasn't able to get HOOK__search_api_query_alter or HOOK_search_api_results_alter to fire, so I am attempting to manipulate the query through HOOK_views_query_alter.
I have attempted to use both the "addWhere" and "addCondition" methods with the following syntax:
When using the addCondition method, I attempted
$query->addCondition('search_api_db_default_index.nid', $oneBadNid, '<>');
and
$query->addCondition('search_api_db_default_index.nid', $manyBadNids, 'NOT IN');
and when using the addWhere method, I attempted
$query->addWhere('AND', 'search_api_index_default_index.nid', $oneBadNid, '<>');
and
$query->addWhere('AND', 'search_api_index_default_index.nid', $manyBadNids, 'NOT IN');
Regardless of whether or not I prefix the field with the table name, searching always results in triggering the following notice:
Unknown field in filter clause: 'search_api_db_default_index.nid' .
It seems that the field name is always wrapped in an html encoded string representing a single quotation, but this occurs both when using double quotations or single quotations around the supplied table.field parameter.
I am not even sure that this is what is keeping me from altering my query, but it is the only thing close to an error which I have discovered in this process. It's also possible that I'm simply not supposed to be targeting the table in the manner written, but I did not find any documentation directing me to the proper methodology.
I would appreciate any insight into this issue! Thanks!
Generally you can use
$fields = $query->getIndex()->getFields();
on the query to get an array of fields you can use within the search_api query.
Piggy-backing off of Nebel54's comment, and attempting this on my own, you don't need to include the 'table' name when setting the addCondition. However, I did need to use hook_search_api_query_alter over a views-specific one.
function mymodule_search_api_query_alter(\Drupal\search_api\Query\QueryInterface &$query) {
// Ensure field_myfield is being indexed
$fields = $query->getIndex()->getFields();
if (isset($fields['field_myfield'])) {
$query->addCondition('field_myfield', 'myvalue', '<>');
}
}

How to return only indexed objects of a specific type in Haystack

Is there any way to use SearchQuerySet and restrict the results to only a specific indexed model? i.e. If i add Note and NoteIndex to Haystack, can I pull out just results that correspond to Note instances?
EDIT:
I have had a look and found that there is a reserved field named django_ct that is stored on every indexed model. Is it possible to filter on this field? What values does it take?
DOUBLE EDIT:
Nevermind. After reading the Haystack source code, django_ct is 'appname.modelname' internally and can be querired with SearchQuerySet.filter(django_ct = 'appname.modelname')
According to the Haystack documentation, a SearchQueryset object has a method called models() that restricts the results to those models.
e.g.
SearchQuerySet().models(BlogEntry, Comment).filter(content='foo')
As you see, it uses the actual model class. My guess is that it uses this to lookup the content-type to perform filter.