Netsuite and Scribe Online - Filtering - filter

I am using Scribe Online as an integration service, facilitating the exchange of data between Netsuite and IBM Cloud (formerly SilverPop). In Scribe it's possible to filter the queries made to Netsuite and so narrow the data retrieved.
While I can set the filter to fetch records where e.g. 'internalid is greater than 100;' the condition where 'internalid is less than 100' is not supported; and using a date produces similar result. It seems that 'less than' is not supported and Scribe Support suggest this may be a limitation of Netsuite's API.
How can I filter within a range of criteria e.g. a date range or a numerical range?
Does Netsuite's API limit this kind of filtering or are there ways to achieve it?

I am not familiar with Scribe, but here is how this is accomplished within NetSuite itself.
To compare an Internal ID as a number, you need to use the field internalidnumber instead of internalid. internalid is a String, so the less than operator isn't applicable.
Dates use very different operators. Instead of less, for Dates you would use operators like between, before, after, onorbefore, onorafter. There is a NetSuite Help document titled Search Operators that enumerates all possible search operators and which types of fields they apply to.

Related

AWS Quicksight calculated field vs Custom SQL query

As with any other BI tool AWS Quicksight allows you to add calculated fields. So far, I haven't run into any limitations using them, but I can't help but wonder what is the better design approach? Adding a calculated field in my custom SQL query or using the calculated fields feature?
So there is a few ways to work with calculated fields in Quicksight:
You do them in your SQL query
You add them to your dataset
You add them to your analysis
I am not sure if this would be considered best practice, but my preference has evolved to:
Use calculated fields on an analysis, if I want to contain that field to the analysis only.
If the field will be used more than once, I add them to the dataset. This is my go-to method if I am not using a direct query and relying on the default UI.
For any complicated calculations that are not supported by Quicksight calculated fields or if I am already using a direct query, I'll do everything in SQL.
The downside of calculated fields is that looking up their computation can be a little annoying as it involves a few clicks. Also, I find it hard to differentiate between which fields are calculated and which aren't so I have a habit of prefixing calculated fields with _, e.g. _date or _day_of_week if it is a calculated field.

How to sort (and give weight) by Availability dates in SolR

i'm facing a big problem in my SolR DB.
My objects have a datetime field "Available_From" and a datetime field "Available_To".
We also have a "Ranking" field for the sorting.
I can search correctly with direct queries (eg. give me all the items that are available at the moment) but when i do a regular search i cannot find a way to show the items that result "available NOW" in the first places in the results, usually sorted by "Ranking" field.
How can i do this? Am I forced to write some java classes (the nearest thing i've found is there https://medium.com/#devchaitu18/sorting-based-on-a-custom-function-in-solr-c94ddae99a12) or is there a way to do with standard SolR queries?
Thanks in advance to everyone!
In your case you actually don't want sorting, since that indicates that you want one field to determine the returned sequence of documents.
Instead, use boosting - apply a very large boost to those that are available now, either through bq or boost, then apply a boost based on ranking. You'll have to tweak the weights given to each part based on how you want the search results to be presented.

FHIR: How to Get List of Patients and Most Recent RiskAssessments

Based on FHIR spec, I know I can do a search on patients and ask that all RiskAssessments be included for each patient (using _revinclude) -- but what if I'm interested only in the most recent RiskAssessment? Or better yet, the most recent RiskAssessment for a specific RiskAssessment.method. Is there a way to accomplish this with a single query?
You could query on RiskAssessment and do a forward include of Patient. If you do that, you can then filter on method. (And via chaining, also filter on what patients to include). There's no way to do "most recent" and get back multiple patients. (For a single patient, sort by descending date and restrict to only 1 instance). However, you could define your own search parameter to assert that filter. (You can also submit a change request to propose such a parameter be defined in general - I'd recommend making the parameter an integer so that you can retrieve the N most recent.)

Elasticsearch autocomplete and searching against multiple term fields

I'm integrating elasticsearch into an asset tracking application. When I setup the mapping initially, I envisioned the 'brand' field being a single-term field like 'Hitachi', or 'Ford'. Instead, I'm finding that the brand field in the actual data contains multiple terms like: "MB 7 A/B", "B-7" or even "Brush Bull BB72X".
I have an autocomplete component setup now that I configured to do autocomplete against an edgeNGram field, and perform the actual search against an nGram field. It's completely useless the way I set it up because users expect the search results to be restricted to what the autocomplete matches.
Any suggestions on the best way to setup my mapping to support autocomplete and subsequent searches against a multiple term field like this? I'm considering a terms query against a keyword field, or possibly a match query with 'and' as the operator? I also have to deal with hyphens like "B-7".
you can use phrase suggest, the guide is here:
http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-suggesters.html
the phrase suggest guide is here:
http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-suggesters-phrase.html

Give advantage to search by phrase in sort SOLR

Search query which I send to SOLR is:
?q=iphone 4s&sort=sold desc
By default the search works great, but the problem appears when I want to
sort results by some field for eg. sold - No. of sold products.
SOLR finds all the results which have: (iphone 4s) or (iphone) or (4s)
So, when I apply sort by field 'sold' first result is: "iPhone 3GS..." which is problem.
I need the results by phrase ("iphone 4s") first and then the rest of the results - all sorted by sold.
So, the questions are:
Is it possible to have query like this, and how?
q=iphone 4s&sort={some algoritam for phrase results first} desc, sold desc
Or, can I perform this by setting up query analyzer and how?
At the moment this is solved by sending 2 requests to SOLR,
first with phrase "iphone 4s" and, if this returns 0 results,
I perform second request without the phrase - only: iphone 4s.
If sorting by score, id, field is not sufficient, Lucene lets you implement custom sorting mechanism by providing your own subclass of FieldComparatorSource abstract base class.
With in that custom-sort-logic, you can implement the way that realizes your requirements.
Example Java code:
If(modelNum1.equals(modelNum2)){
//return based on number of units sold.
}else{
//ALWAYS return a value such that the preferred model beats others.
}
DISCLAIMER: This may lead to maintenance problems as you will have to change the logic when a new phone model arrives.
Steps:
1) Sort object accepts FieldComparatorSource type instance during instantiation.
2) Extend the FieldComparatorSource
3) You've to load the required field information that participates in 'SORTING' using FieldCache within the FieldComparatorSource in setNextReader()
4) Override the FieldComparatorSource.newComparator() to return your custom FieldComparator.
5) In the method FieldComparator.compare(slot1DocId, slot2DocId), you may include your custom logic by accessing the corresponding field information, via loaded FieldCache, using the docIds passed in.
Incorporating Lucene code into Solr as a plug-in should not trouble you..
EDIT:
Can not use space in that function. Term is only without space.
As of Solr3.1, sorting can also be done on arbitrary function queries
(as in FunctionQuery) that produce a single value per document.
So, I will use function termfreq in sort
termfreq(field,term) returns the number of times the term appears in
the field for that document.
Search query will be
q=iphone 4s&sort=termfreq(product_name,"iphone 4s") desc, sold desc
Note: The function termfreq is active from Solr 4.0 version

Resources