Hi,
Le 02/04/2013 10:08, Chris forum a écrit : > Still struggling with the search function. > > To resume what I am experiencing with a 2 fields search, which > consists in finding a street name and then a building number on this > street: > > 1) It looks like I can not set the first field search mode to > 'options', my postgis table is too big (~10'000 rows). > If I do, even though the values are there (Firebug can lists the > option values), they are not displayed in the drop down menu. > > 2) When I set the first field mode to 'suggest', it works but the > query is launched as soon as I click on a proposed value. > So when I click on a street name, the query is done before I can > specify a building number. > I don't remember how to do this, but i'm sure a suggest field is able to not send search > Is a two fields search supposed to work with both fields using > 'suggest' mode? > If so, do you have any idea why the search doesn't wait for the second > input before launching the query? I will check code, but it shoudl work as you discribed. > > Any working exemple available? > Link to the gisdb postgis table used in the dev search.xml? Could you send me small SQL scripts to create and populate DB (and the corresponding mapfile layer part) please? > > > Thanx, > Chris > > > > > > > > > On Wed, Mar 27, 2013 at 3:56 PM, Chris forum <bak.fo...@gmail.com > <mailto:bak.fo...@gmail.com>> wrote: > > Hi Thomas, > > Thx for your fast reply! > > The <searchitem> of my last message was related to a shapefile for > a test. That's why I didn't add an SQL query in it as I didn't see > any shapefile example with an sql tag. > Anyway, I just tried to add: > <sql>SELECT DISTINCT NUMBER FROM building _shp"> > WHERE TYPE = '[dependfldval]' AND NUMBER ~* '[search]' ORDER BY > NUMBER </sql> > > But the second field is still not filtered... : ( > > From what I see, you example with 2 fields is dealing with a PGSQL > table. > Here is what I have: > <searchitem name="addresses" description="Addresses -Suggest > Suggest PGSQL-"> > <layer type="postgis" name="Address_table"> > > <field type="s" name="Address_field" description="Street" > wildcard="2"> > <definition type="suggest" connectiontype="db" minlength="1" > startleft="1" sort="asc"> > <dsn encoding="UTF-8">pgsql://user:pass@localhost/db</dsn> > <sql>SELECT DISTINCT Address_field FROM public.Address_table WHERE > Address_field IS NOT NULL ORDER BY Address_field</sql> > <events>onchange="$('#pmsfld_number_field').val('').flushCache()"</events> > </definition> > </field> > > <field type="n" name="Number_field" description="Nb" > wildcard="2"> > <definition type="suggest" connectiontype="db" > sort="asc" minlength="3" dependfld="Address_field"> > <dsn > encoding="UTF-8">pgsql://user:pass@localhost/db</dsn> > <sql>SELECT DISTINCT Number_field FROM > public.goeland_addresse_lausanne WHERE Number_field ~* '^[search]' > {and Address_field = '[dependfldval]'} ORDER BY Number_field</sql> > </definition> > </field> > > </layer> > </searchitem> > > First field works, but the query is made as soon as I choose one > entry in the list. No chance to select anything on the 2nd field. > If I switch the first field mode to 'options', the drop down menu > comes empty. Actually the values are in there, but just not > displayed... very strange. > > In case the problem is there, here under the related layer of my > mapfile: > LAYER > NAME "Address_table" > TYPE POINT > DATA "geom from Address_table using unique idaddress using > srid=21781" > CONNECTIONTYPE postgis > CONNECTION "user=user password=pass dbname=db host=localhost > port=5432" > METADATA > "DESCRIPTION" "Addresses" > "RESULT_FIELDS" "idaddress, Address_table, Number_field" > "RESULT_HEADERS" "ID, Street, Nb" > "ows_title" "addresses" > END > TEMPLATE void > CLASS > STYLE > SYMBOL "circle" > COLOR 255 0 125 > MINSIZE 1 > SIZE 6 > MAXSIZE 10 > END > END > END > > Do you see anything wrong/missing? > > > > > > On Wed, Mar 27, 2013 at 2:55 PM, Thomas RAFFIN <traf...@sirap.fr > <mailto:traf...@sirap.fr>> wrote: > > I think you have to define the SQL query for suggest option > with depend > field val. Here is an example for the 2d field that depend on > field1 > > <field type="s" name="field2" description="Field 2" > wildcard="0" size="15"> > <definition type="suggest" connectiontype="db" > startleft="1" sort="asc" minlength="4" dependfld="field1"> > <dsn encoding="UTF-8">@</dsn> > <sql>SELECT DISTINCT field2 FROM > schema.table WHERE > field1 = '[dependfldval]' AND field2 ~* '[search]' ORDER BY > field2</sql> > <events></events> > </definition> > </field> > > NB: it is possible to use many depend fields, but if it > doesn't works > already, maybe I've forgotten to commit something... > <field type="s" name="field1" description="Field 1" > wildcard="0" size="15"> > > <events>onchange="$('#pmsfld_field2').val('');$('#pmsfld_field2').flushCache();"</events> > </field> > <field type="s" name="field2" description="Field 2" > wildcard="0" size="15"> > <definition type="suggest" connectiontype="db" > startleft="1" sort="asc" minlength="4" dependfld="field1"> > <dsn encoding="UTF-8">@</dsn> > <sql>SELECT DISTINCT field2 FROM > schema.table WHERE > field1 = '[dependfldval]' AND field2 ~* '[search]' ORDER BY > att1</sql> > > <events>onchange="$('#pmsfld_field3').val('');$('#pmsfld_field3').flushCache();"</events> > </definition> > </field> > <field type="s" name="field3" description="Field 3" > wildcard="0" size="15"> > <definition type="suggest" connectiontype="db" > startleft="1" sort="asc" minlength="4" dependfld="field1,field2"> > <dsn encoding="UTF-8">@</dsn> > <sql>SELECT DISTINCT field3 FROM > schema.table WHERE > field1 = '[dependfldval_field1 ]' AND field2 = > '[dependfldval_field2]' > AND field3 ~* '[search]' ORDER BY field3</sql> > <events>....</events> > </definition> > </field> > > Le 27/03/2013 14:15, Chris forum a écrit : > > Hi all, > > > > I am having a hard time getting to work a search with 2 > fields, second one > > being dependant of the first one. > > I especially would like to do that with data coming from PGSQL . > > > > I know there are examples in the search.xml of the wiki, but > I am not able > > to reproduce them with the demo data: > > - "Cities Options Suggest MS": P.MAPPER ERROR: This version > of PHP does > > support dBase functions > > - "Communes Suggest PG": I can not find where to download > the PGSQL > > database gisdb > > > > Does anyone have a link where to get gisdb database? > > > > Here under what I tried with my own shapefile data. > > This sort of work, but the second field is not filtered > according to what > > has been chosen on the first field. > > > > <searchitem name="Test" description="Test -Options Suggest MS-"> > > <layer type="shape" name="building _shp"> > > > > <field type="s" name="TYPE" > description="Building Type" > > wildcard="2"> > > <definition type="options" > connectiontype="ms" > > sort="asc" firstoption="*"> > > <mslayer encoding="ISO-8859-1" > keyfield="TYPE" > > showfield="TYPE"/> > > > > > <events>onchange="$('#pmsfld_NUMBER').val('').flushCache()"</events> > > </definition> > > </field> > > > > <field type="s" name="NUMBER" > description="Building > > Number" wildcard="2"> > > <definition type="suggest" > connectiontype="ms" > > minlength="1" startleft="1" sort="asc" dependfld="TYPE"> > > <mslayer encoding="ISO-8859-1" > keyfield="NUMBER" > > showfield="NUMBER"/> > > </definition> > > </field> > > > > </layer> > > </searchitem> > > > > > > Regards, > > Chris > > > > ------------------------------------------------------------------------------ > > Own the Future-Intel® Level Up Game Demo Contest 2013 > > Rise to greatness in Intel's independent game demo contest. > > Compete for recognition, cash, and the chance to get your game > > on Steam. $5K grand prize plus 10 genre and skill prizes. > > Submit your demo by 6/6/13. http://p.sf.net/sfu/intel_levelupd2d > > _______________________________________________ > > pmapper-users mailing list > > pmapper-users@lists.sourceforge.net > <mailto:pmapper-users@lists.sourceforge.net> > > https://lists.sourceforge.net/lists/listinfo/pmapper-users > > > > > > -- > > > Thomas RAFFIN > Chef de Projet Internet > traf...@sirap.fr <mailto:traf...@sirap.fr> > <mailto:traf...@sirap.fr <mailto:traf...@sirap.fr>> Sirap > <http://sirap.fr> Tel > : 04 75 72 84 10 > Fax : 04 75 70 07 98 > Rue Paul Louis Héroult - BP 253 > 26106 Romans cedex > > > ------------------------------------------------------------------------------ > Own the Future-Intel® Level Up Game Demo Contest 2013 > Rise to greatness in Intel's independent game demo contest. > Compete for recognition, cash, and the chance to get your game > on Steam. $5K grand prize plus 10 genre and skill prizes. > Submit your demo by 6/6/13. http://p.sf.net/sfu/intel_levelupd2d > _______________________________________________ > pmapper-users mailing list > pmapper-users@lists.sourceforge.net > <mailto:pmapper-users@lists.sourceforge.net> > https://lists.sourceforge.net/lists/listinfo/pmapper-users > > > -- Thomas RAFFIN Chef de Projet Internet traf...@sirap.fr <mailto:traf...@sirap.fr> Sirap <http://sirap.fr> Tel : 04 75 72 84 10 Fax : 04 75 70 07 98 Rue Paul Louis Héroult - BP 253 26106 Romans cedex ------------------------------------------------------------------------------ Own the Future-Intel(R) Level Up Game Demo Contest 2013 Rise to greatness in Intel's independent game demo contest. Compete for recognition, cash, and the chance to get your game on Steam. $5K grand prize plus 10 genre and skill prizes. Submit your demo by 6/6/13. http://altfarm.mediaplex.com/ad/ck/12124-176961-30367-2 _______________________________________________ pmapper-users mailing list pmapper-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/pmapper-users