svySearch

Questions and answers on designing your Servoy solutions, database modelling and other 'how do I do this' that don't fit in any of the other categories

svySearch

Postby Peter de Groot » Wed Nov 16, 2016 1:24 pm

Thank you for sharing this module/solution, works very very good and very easy to implement in our solution (any solution)..

Regards,

Peter
User avatar
Peter de Groot
 
Posts: 215
Joined: Thu Jan 10, 2008 8:38 pm
Location: Not sure...

Re: svySearch

Postby sean » Wed Nov 16, 2016 9:53 pm

Hi Peter,

Excellent! I'm Glad that you are finding success.

If you find any issues or have ideas to improve the module, please post to the project's issues page.
Software Engineer
Servoy USA
sean
 
Posts: 370
Joined: Mon May 21, 2007 6:26 pm
Location: USA

Re: svySearch

Postby alk » Fri Feb 17, 2017 9:27 pm

Hi Sean,
I am trying to install svySearch,
Running it I get the following message:

TypeError: Cannot read property "column" from (F:\Eigene Dateien\servoy_workspace_bib\svySearch\svySearch.js#845)
at F:\Eigene Dateien\servoy_workspace_bib\svySearch\svySearch.js:845
at F:\Eigene Dateien\servoy_workspace_bib\svySearch\svySearch.js:558
at F:\Eigene Dateien\servoy_workspace_bib\svySearch\svySearch.js:665
at F:\Eigene Dateien\servoy_workspace_bib\BIB_Basic\forms\frm_verlag.js:77 (onSearch)

Any help possible?
Thanks and greatings from Berlin

Ralf
alk
 
Posts: 61
Joined: Wed May 21, 2014 8:34 pm
Location: Berlin

Re: svySearch

Postby sean » Fri Feb 17, 2017 11:01 pm

Hi Ralf,

Looking at the svySearch.js line#845 from your stack trace, it doesn't line up with anything from latest build.
What version of svySearch do you run ?

I assume it breaks because you have specified a column name as a search provider and it doesn't resolve when the search is executed.

Please double-check your searchProviders and verify that they match a real column
I have a TODO in the code to add a check for this and throw a more meaningful error if that happens
Software Engineer
Servoy USA
sean
 
Posts: 370
Joined: Mon May 21, 2007 6:26 pm
Location: USA

Re: svySearch

Postby alk » Sat Feb 18, 2017 2:42 pm

Hallo Sean,
thanks for your fast answer:
First of all ( I do not known wy) the file was corrupted (so I did download version 1.10 again...)

Second: I do have a table and a column with the same name,
what shall I do?

Third: I get another error message
TypeError: Cannot call method "createSimpleSearch" of undefined (F:\Eigene Dateien\servoy_workspace_bib\BIB_Basic\forms\frm_verlag.js#36)
at F:\Eigene Dateien\servoy_workspace_bib\BIB_Basic\forms\frm_verlag.js:36 (onSearch)

And:
I get some warnings...
Description Resource Path Location Type
Function getContainedForms declares Array<RuntimeForm> as type but doesn't return anything svyUI.js /svyUtils line 525 JavaScript Problem
Function getContainerElements declares Array<RuntimeTabPanel|RuntimeSplitPane|RuntimeAccordionPanel> as type but doesn't return anything svyUI.js /svyUtils line 535 JavaScript Problem
The method addSearchProvider() is undefined for object search frm_verlag.js /BIB_Basic/forms line 59 JavaScript Problem
The method addSearchProvider() is undefined for object search frm_verlag.js /BIB_Basic/forms line 104 JavaScript Problem
The method loadRecords() is undefined for object search frm_verlag.js /BIB_Basic/forms line 77 JavaScript Problem
The method loadRecords() is undefined for object search frm_verlag.js /BIB_Basic/forms line 125 JavaScript Problem
The method loadRecords() is undefined for object search frm_verlag.js /BIB_Basic/forms line 143 JavaScript Problem
The method setCaseSensitive() is undefined for object searchProvider frm_verlag.js /BIB_Basic/forms line 105 JavaScript Problem
The method setSearchText() is undefined for object search frm_verlag.js /BIB_Basic/forms line 39 JavaScript Problem
The property svySearch is undefined for the type Scopes<BIB_Basic> frm_verlag.js /BIB_Basic/forms line 36 JavaScript Problem
The property svySearch is undefined for the type Scopes<BIB_Basic> frm_verlag.js /BIB_Basic/forms line 89 JavaScript Problem
The property svySearch is undefined for the type Scopes<BIB_Basic> frm_verlag.js /BIB_Basic/forms line 101 JavaScript Problem
The property svySearch is undefined for the type Scopes<BIB_Basic> frm_verlag.js /BIB_Basic/forms line 115 JavaScript Problem
The property svySearch is undefined for the type Scopes<BIB_Basic> frm_verlag.js /BIB_Basic/forms line 135 JavaScript Problem
Unknown type Runtime svyUI.js /svyUtils line 531 JavaScript Problem

???

Thanks in advance
Ralf
alk
 
Posts: 61
Joined: Wed May 21, 2014 8:34 pm
Location: Berlin

Re: svySearch

Postby sean » Tue Feb 21, 2017 10:42 pm

Hi Ralf,

1. The table and column having same name should not be a problem.

2. The errors suggest that the svySearch module is really not loaded, becasue createSimpleSearch() is right on the top-level scope.
All the subsequent errors come from that. Please be sure that the module is included in your module list

I hope this helps.
Software Engineer
Servoy USA
sean
 
Posts: 370
Joined: Mon May 21, 2007 6:26 pm
Location: USA

Re: svySearch

Postby alk » Tue Feb 28, 2017 12:00 pm

Hi Sean (and maybe others),

I am sorry to bother you again.
It will not work...

What I did
a) I include sysSearch als modul
b) I installed a textfield with the dataprovider "searchText" and name "searchText" on my form
c) I installed a onAction-Event called "onSearch" in this field
d) I copied the functons
+ "on Search"
+ "onSearch$basic"
+ "onSearch$caseInsentive"
+ "onSearch$explizit$dateFormat"
+ "onSearch$substitutions"
from the example
I changed the searchProviders and commented the other examples.
I asume the "onSearch$basic" is enough...

But I get the following Type Error
------------------------------------------------------
TypeError: Cannot read property "column" from (F:\Eigene Dateien\servoy_workspace_bib\svySearch\svySearch.js#857)
at F:\Eigene Dateien\servoy_workspace_bib\svySearch\svySearch.js:857
at F:\Eigene Dateien\servoy_workspace_bib\svySearch\svySearch.js:570
at F:\Eigene Dateien\servoy_workspace_bib\svySearch\svySearch.js:677
at F:\Eigene Dateien\servoy_workspace_bib\BIB_Basic\forms\frm_verlag.js:89 (onSearch)
------------------------------------------------------

Here the marked lines(and some before and after):
++++++++++++++++++++++++
F:\Eigene Dateien\servoy_workspace_bib\svySearch\svySearch.js:857
this.getJSColumn = function(){
return parseJSColumnInfo(search.getDataSource(),dataProviderID).column;
}
++++++++++++++++++++++++
F:\Eigene Dateien\servoy_workspace_bib\svySearch\svySearch.js:570
// SKIP NON-TEXT types for implied search
type = sp.getJSColumn().getType();
if(type != JSColumn.TEXT){
// TODO Warn of implied search for non-text columns ?
continue;
}
+++++++++++++++++++++++
F:\Eigene Dateien\servoy_workspace_bib\svySearch\svySearch.js:677
this.loadRecords = function(foundSet){
return foundSet.loadRecords(this.getQuery());
}
++++++++++++++++++++++++

at F:\Eigene Dateien\servoy_workspace_bib\BIB_Basic\forms\frm_verlag.js:89 (onSearch)
search.loadRecords(foundset);
application.output(databaseManager.getSQL(foundset));
application.output(databaseManager.getSQLParameters(foundset));

}
+++++++++++++++++++++++++

By the way
Thanks for the webinar-series !
(i tried to find the datebase "example_data" you use for yor examples, but couldn`'t find it in the other servoy examples,
any chance to get them for your demos?

Thanks a lot
Ralf
alk
 
Posts: 61
Joined: Wed May 21, 2014 8:34 pm
Location: Berlin

Re: svySearch

Postby Bernd.N » Tue Feb 28, 2017 12:12 pm

Hi Ralf,
are you using the Servoy Debugger in Eclipse?
With that you could put a breakpoint at that line where the error appears:
Code: Select all
return parseJSColumnInfo(search.getDataSource(),dataProviderID).column;

Then you could inspect the two parameters search.getDataSource() and dataProviderID.

Another way would be to put an
Code: Select all
application.output(search.getDataSource());
application.output(dataProviderID);

in front of that line, to see then in Servoy Console what they contain.

And you could also look at the function parseJSColumnInfo (if that is in the sourcecode which I do not know) if you can detect a possible bug there.
IMHO, that function does return something that will not make sense then together with .column behind it.
Bernd Korthaus
LinkedIn
Servoy 7.4.9 SC postgreSQL 9.4.11 Windows 10 Pro
User avatar
Bernd.N
 
Posts: 544
Joined: Mon Oct 21, 2013 5:57 pm
Location: Langenhorn, North Friesland, Germany

Re: svySearch

Postby alk » Tue Feb 28, 2017 3:08 pm

Hi Bernd,

I will try that...
Ralf
alk
 
Posts: 61
Joined: Wed May 21, 2014 8:34 pm
Location: Berlin

Re: svySearch

Postby Bernd.N » Tue Feb 28, 2017 4:29 pm

I think it is not likely that the program has a bug, but that the setup so far leads to a value not being correctly set, either the dataSource or the dataProviderID.
Bernd Korthaus
LinkedIn
Servoy 7.4.9 SC postgreSQL 9.4.11 Windows 10 Pro
User avatar
Bernd.N
 
Posts: 544
Joined: Mon Oct 21, 2013 5:57 pm
Location: Langenhorn, North Friesland, Germany

Re: svySearch

Postby sean » Tue Feb 28, 2017 5:00 pm

Hi Ralf,

Thanks for your persistence in using this module.

It looks like you are trying to run the same code from the sample solution?
The error you get indicates that there is no column found for the SearchProvider that was added.
(I have just added some additional logging to show which column/table it is. This is committed and will be in the next release)

In the meantime, can you confirm that you have the example_data database connected?

The easiest way to get started is to download the latest release for the svySearchExample solution. When you import the solution, you will have the option to auto-create the example database.

Additionally, when you install Servoy Developer, you can opt to include a bundled Postgresql installation with the example databases.
I think this also answers your question about the Save Data Example ?
Software Engineer
Servoy USA
sean
 
Posts: 370
Joined: Mon May 21, 2007 6:26 pm
Location: USA

Re: svySearch

Postby alk » Tue Feb 28, 2017 5:58 pm

Hallo Sean

Thanks for your fast answer:
I have the enterprise version of postgres, therefore the databse is not imported.
Wenn I use the way "import the sysSearchExample" the tables are build in the existing database "example_data" but no data is imported.
What to do?

When I start the example Solution I get this strange screen the operation is runing an druning:
Mainbase.JPG
Mainbase.JPG (52.06 KiB) Viewed 8439 times


Any idea what this is?

Back to your answer
Quote:
"The error you get indicates that there is no column found for the SearchProvider that was added."
Question:
I named the Searchprovider(e.g. "titel", "autor") and of course the table=serachprovider has columns.
Do I have also to name the single colums of every table ( e.g. "lastname". "firstname") and where do I find these definitions or I am runing the comple wrong direction?

Best
Ralf
alk
 
Posts: 61
Joined: Wed May 21, 2014 8:34 pm
Location: Berlin

Re: svySearch

Postby sean » Tue Feb 28, 2017 6:48 pm

Hi Ralf,

There is an option to import sample data when importing. Did you select it?

It appears that your IDE is stuck "building" which is blocking other actions.
Not sure why, you may need to restart IDE. But this is unrelated to search.

Finally, I don't understand your second question completely.
It doesn't matter what you name the SearchProvider. The "alias" is for explicit searches, i.e. "country:germany"

But the column name must match what is in the DB.
Can you please share your code where you are calling addSearchProvider ?
Software Engineer
Servoy USA
sean
 
Posts: 370
Joined: Mon May 21, 2007 6:26 pm
Location: USA

Re: svySearch

Postby alk » Tue Feb 28, 2017 7:17 pm

It seams am a heavy case ;-)

I downloaded again the example solution and imported it.
I was asked to import data and during importing I get this warning
Warning.JPG
Warning.JPG (22.96 KiB) Viewed 8435 times


I said "ok",

Here a screenshot from pgadmin:
pgdamin.JPG
pgdamin.JPG (38.27 KiB) Viewed 8435 times


but all tables like "order_details" are empty
pgdamin-2.JPG
pgdamin-2.JPG (31.02 KiB) Viewed 8435 times


So now my complete code for OnSearch, etc.

/**
* @type {String}
*
* @properties={typeid:35,uuid:"DB950707-C0D8-402D-A2BC-F98E813413CB"}
*/
var searchText = '';


/**
* @properties={typeid:24,uuid:"DB3765B8-785D-4533-9A21-3DAC5CEEE6AE"}
*/
function onSearch(){

// load all records when search is cleared
if(!searchText){
foundset.loadAllRecords();
return;
}

// create search object and add search providers
var search = scopes.svySearch.createSimpleSearch(foundset);

// set the search text
search.setSearchText(searchText);

// list of data providers to include in search
var searchProviders = [
'autor',
'titel',
'verlag',
'verlagsort',

// related data providers
//'orders_to_customers.companyname',
//'orders_to_employees.firstname',
//'orders_to_employees.lastname',

// N-levels depth on relations
//'orders_to_order_details.order_details_to_products.productname'
];

// add search providers
for(var i in searchProviders){
search.addSearchProvider(searchProviders[i]);
}

// add order date as an explicit search
//search.addSearchProvider('orderdate')
// .setAlias('ordered') // specify the alias which may be used
// .setImpliedSearch(false) // specify that the column is not searched unless explicitly specified

// add freight as an explicit search
//search.addSearchProvider('freight')
// .setImpliedSearch(false) // specify that the column is not searched unless explicitly specified

// add product status, use substitutions to parse display values for integers
//search.addSearchProvider('orders_to_order_details.order_details_to_products.discontinued','product-status')
// .addSubstitution('active',0)
// .addSubstitution('inactive',-1)

// execute search
search.loadRecords(foundset);
application.output(databaseManager.getSQL(foundset));
application.output(databaseManager.getSQLParameters(foundset));

}


/**
* @properties={typeid:24,uuid:"7866937F-8589-4C20-9BBD-916379E98643"}
*/
function onSearch$basic(){
scopes.svySearch.createSimpleSearch(foundset)
.setSearchAllColumns()
.setSearchText(searchText)
.loadRecords(foundset);
}


/**
* @properties={typeid:24,uuid:"99112917-1AEB-41F6-A5ED-EC4293DB1FA6"}
*/
function onSearch$caseInsensitive(){

var search = scopes.svySearch.createSimpleSearch(foundset)
.setSearchText(searchText);

var searchProvider = search.addSearchProvider('kuenstlerart');
searchProvider.setCaseSensitive(false);
}


/**
* @properties={typeid:24,uuid:"691E0656-E4F0-4BCF-866E-157F492FB883"}
*/
function onSearch$explicit$dateFormat()
{
// create the search
var search = scopes.svySearch.createSimpleSearch(foundset)
.setSearchText(searchText) // set the search text
.setDateFormat('dd.MM.yyyy'); // Set the date format which is used

// add order date as an explicit search
//search.addSearchProvider('orderdate')
// .setAlias('ordered') // specify the alias which may be used
// .setImpliedSearch(false) // specify that the column is not searched unless explicitly specified

// run search
search.loadRecords(foundset);
}


/**
* @properties={typeid:24,uuid:"3AABF4A7-0089-4347-8559-F163B5EF40D1"}
*/
function onSearch$substitutions(){

// create the search
var search = scopes.svySearch.createSimpleSearch(foundset)
.setSearchText(searchText) // set the search text

//search.addSearchProvider('shipcountry')
// .addSubstitution('fr','France')
// .setAlias('country');

// execute search
search.loadRecords(foundset);
application.output(databaseManager.getSQL(foundset));
application.output(databaseManager.getSQLParameters(foundset));
}

To complet the story
a) the structure of the table "autor"
CREATE TABLE public.autor
autor_id character varying(36) NOT NULL,
alt_au_id integer,
nachname character varying(40),
vorname character varying(40),
erfass_dat date,
aender_dat date,
name_match character varying(90),
CONSTRAINT autor_pkey PRIMARY KEY (autor_id)

b) the structure of the taabke "verlag"
CREATE TABLE public.verlag
verlag_id character varying(36) NOT NULL,
alt_vlg_id integer,
verlagsname character varying(60),
isbnkurz character varying(12),
erfass_dat date,
aender_dat date,
CONSTRAINT verlag_pkey PRIMARY KEY (verlag_id)

Sean, I really apprciate your time and help....
Sorry for the long post.

Thanks a lot

Ralf
alk
 
Posts: 61
Joined: Wed May 21, 2014 8:34 pm
Location: Berlin

Re: svySearch

Postby sean » Tue Feb 28, 2017 7:51 pm

Hi Ralf,

It could be that the release does not have sample data included. (If not, sorry for that!)

I just did an export from the latest source for you with sample data, attached here.
You can re-import and it should fill your tables.

Also it has that logging change I made, which should show any columns that weren't found.
Attachments
svySearchExample.servoy
Example Solution with data
(176.63 KiB) Downloaded 234 times
Software Engineer
Servoy USA
sean
 
Posts: 370
Joined: Mon May 21, 2007 6:26 pm
Location: USA

Next

Return to Programming with Servoy

Who is online

Users browsing this forum: No registered users and 5 guests