I have a table in the database:
name Opinion
Tim Tim has an opinion
John other random text
Dan Dan's random text
Al Al says something else
I call this data and get it back in
getRecords.lastResult
To access John's opinion, I could use:
getRecords.lastResult[1].opinion
But that's only because I know that John is the second record (record 1), but this may change. So the right way is to search through the results to first find the record index for John, then access his opinion.
My guess is I need some sort of a loop? Is there an easier way to search for John directly without a loop?
Well if getRecords returns n records and John has to be on one of them
you can do it in As3 and do a loop around your Arraycollection until you find John.
Or
Do some server logic to return john data given a search string ("john") if unique.
Related
I have created a lookup table of employee name text file referring to the rasa blog(link below).
Improving entity extractions with Rasa
Now my use case also requires me to give synonyms to these employees in the lookup table. For example, “Nicholas” can also be referred to as “Nick” or “Nic”, so that the rasa bot can extract “nick” as “nicholas” and fulfill the use case.
Please advice how to achieve this.
Thanks
Lookup and synonyms have a different purpose as while, lookups are used for entity extraction, synonyms are used as a filtration method to change the format of any synonyms to original text. Therefore, I think, you can't have synonyms within the lookup table so you might have to do that separately.
However, If you have a long list of synonyms you can use a file path instead of list.
## synonym:Nick
data/path/nick.txt
I had a similar situation with City names and their nick while I was using City name from the lookup but placed their synonyms in the main data file as
## synonym:New York City
- NY
- NYC
- New York
## lookup:city
data/lookups/city_lookup.txt
I recommend using https://github.com/rodrigopivi/Chatito which will really ease the task for you as it has a really good mapping system that does the work for you with regards to synonyms and lookups.
I'm setting up a table of people in DynamoDB, and I'd like to tag those people.
For demonstrations purposes lets say those tags are just strings... "tall", "short", "likes baseball" and so on...
How can I set up the data so I can quickly query all the people with a specific tag, like all the "tall" people?
Can I avoid scanning the table? Can I avoid creating multiple tables? Is this actually a much better use case for relational data structures? What if I come up with new tags on the fly? Relational doesn't work in that case.
Update:
People Tags Mappings
====== ==== ========
John firefighter John > firefighter
Sally young John > young
Joe owner Sally > owner
Anne staff Anne > owner
Chris zebra-lover Chris > zebra-lover
Ben 42 Ben > zebra-lover
In general to avoid scanning when you want to query an attribute which is not the primary key, you can use global secondary keys. For your case that probably doesn't work well, as you might want to be able to tag people with multiple tags at once.
Therefore I'd instead go for a separate table which just contains mappings of tags to people. In that table one item should be the mapping of one tag to one person. If a person has multiple tags, just add multiple items in there.
That way you'd query the tag-table for a given tag to get the primary key of all the people you're searching and would do another query against the people-table afterwards to get their details.
That works for new tags as well, as they'd mean just additional items in the tag-table.
Hoping someone can help me out with a NetSuite question, and I apologize in advance if i’m misusing some lingo.
I am creating a item based saved search and one of my formula (text) result fields can have multiple true values when I apply my case formula. I’m look to combine all the true results of this formula into one comma separated string, instead of a new item row for each true value.
sku contact type
123 John S Owner
123 Jane S Clerk
123 Jack S Clerk
Formula (text) - Custom Label Field Name = Contact Name
Case when {type} = ‘Clerk’ then {contact} end
Currently my results generate a item (sku) row for each case of clerk:
Sku Contact Name
123 Jane S
123 Jack S
I’m looking for my results to be a single string
Sku Contact Name
123 Jane S, Jack S
I know the case function noted above will not string the results by itself; I originally intended to use the group by and max summary types, but I only get one Contact Name result.
Any solutions or work arounds?
Thanks
There are certain grouping functionality available for saved search results, but I don't think what you are trying to do is possible.
If you group your results by Sku, you will get one line per Sku but concenating the contact names from different line results I don't think is possible.
In your SaveSearch's Filter look for mainline and try to set either true(Yes) Or false(No).
There is an undocumented Netsuite function NS_CONCAT() (similar to Oracle's undocumented WM_CONCAT()) that does exactly this. You would group your results by the SKU column, and add formula field with the formula NS_CONCAT({contact}) and the summary type set to Minimum or Maximum.
According to some Netsuite employees on the Netsuite User Group, the LISTAGG function should also work now, and offers more flexibility (if you wanted a delimiter other than a comma for example).
I know this has been asked before..sort of. And that's why I'm posting. Basically I'm building a report in Crystal that relies, to keep this simple, at least 3 tables.
Table A is inner joined to table B by a unique ID. Table B has a child table that may or may not have data related to this unqiue ID.
As a general example table A is a customer table, table B is a product table and the child table is contains the product number. All customers have a product, but not all customers have product number in the child table. I hope I've explained that simply enough.
My issue is sort of between Crytal and Access and how to query this. When I'm writing behind something in VB it's easy enough to write and execute a query and display the result in the desired manner. However I can't seem to get my query straight... I either end up with a report with cartesian product as the resultset, which displays ok...except that even with the few records I have ends up being about 30k pages..or I end up with a blank dataset because the child table does not have corrisponding data to B.
Using outter joins I've managed to get my results within some amount of reason but not acceptable to a real world report. I'm sure this issue has come up but I can't seem to find any suitable answers and to be honest I'm not even sure what questions to ask being a Crystal n00b.
What I'm really after is the data from Table A, the data from Table B and children tables. While they are logically linked and can be linked with the ID field, it isn't necessary I don't think because I am taking a parameter value for the report of the ID field. And once the tables are filtered, no other action needs to be taken except to dump them back on the report.
So can anybody point me in the right direction? Can I set up individual datasoruces (unrelated) based perhaps in a seperate section? Should I build a tree of queries and logic in my DB to get what I need out? I've been racking my brain and can't seem to find the right solution, any and all advice is apreciated and if I can clarify anything or answer any questions I will.
Thanks in advance.
As per requested below:
Section1
ID fname lname
01 john smith
Section2
ID notifiedDate notifiedTime
01 10/10/2012 12:35PM
S2childAdmin
ID noteName
01 jane doe
This data is logically related and can be related in the DB. However it is not necessary as long as the ID parameter is passed to each table. Querying Section1 inner joined with Section2 works fine. But any other arrangements result in more rows than required and I end up with a report many times duplicated. What I really need is something like Section1 joined with Section2 and S2childAdmin as a freely availble table. Otherwise it multiplies my data or results in a null recordset (because it can return 0 rows)
I think this should help point you in the right direction, though it has been 5 years or so since I did heavy Crystal Reports work.
One option might be to join everything using Outer Joins like you stated you were, then use a Crystal Report 'group' on the Table A ID, with a group based upon Table B ID inside of that. So you would, in the actual 'Detail' area put your table C details if there were any, and then use the Group header/footer for Table A and Table B to show data specific to those objects.
Another possible solution that may fall short of your requirements but might get you thinking in another way, is to create your main report and in it, display the fields from table A. Then below those fields include a sub-report and pass in the unique ID from Table A. You will then have a query inside of the subreport that finds all of the Table B records with that Table A.ID value and displays their details.
At this point you run into a weakness of Crystal Reports (at least as of the last version I used) in that you cannot have a subreport inside of a subreport.
I am using ASP.NET 3.5 with VB.net
I have a DataTable as such.
RpID LocationServed
---- --------------
1 St. Louis
1 Baltimore
1 Columbus
2 Chicago
2 St. Charles
2 Peoria
2 Nashville
3 Dallas
3 Miami
3 Indianapolis
What that for each Rep, I need to send an email with all of their Location Served.
I am not quite sure how do do this. I am using ASP.NET 4
My plan is to have 2 loops
<loop1 that has the group by of RepID>
<loop2 can go through the list of items for a given RepID >
strCity = do processing here that will compile a list of the cities for a given rep
</loop2 end>
<send out email a given RepID and then reset strCity >
<loop1 end>
But not quite sure what the best approach is to tackle this.
You can do this one of three ways.
Assuming the DataTable is sorted by RpID, have one loop, process each city. When RpID changes, send an email.
OR...
Loop on the data table. When RpID changes, call .Select on the data table and filter on RpID. Loop on the returned array of DataRows and process each city. Send an email.
OR...
Since you are using ASP.NET 4, you can use a LINQ query to get a distinct list of RpID from the datatable, loop on that list of RpIDs, and then in the loop, use a LINQ query on the datatable to get a list of cities from the datatable for that RpID. Send an email. See here (this talks about a DataSet, but it's the same thing, really)
Note that for any of these approaches, you will have to have a check after the loop to send an email for the last RpID processed.
You can do all this processing in two separate loops.
create a dictionary (possibly sorted) consisting of the Repids as keys and lists of cities as values in a single pass of the table.
process the dictionary. For each key, grab the associated list, (possibly sort it) and send the email.
It'd be a lot quicker than whatever you're proposing. IIRC #1 can be done purely in one LINQ statement as well, see: How to: Group Elements in a Sequence (LINQ to SQL)
Edit: This stackoverflow question seems related Efficient DataTable Group By