Forums / Setup & design / Advanced Search development - 'homemade' fuzzy logic...

Advanced Search development - 'homemade' fuzzy logic...

Author Message

steve walker

Friday 03 September 2004 9:19:24 am

Paul and Hans,

Got it working exactly as I hoped for. The basic code with text form boxes is:

{let carat=ezhttp( 'search_carat', 'get' )}
{let clarity=ezhttp( 'search_clarity', 'get' )}

{let carat_in='('|concat($carat,')') 
let clarity_in='('|concat($clarity,')')

let page_limit=3

let exactresults=fetch(content,tree,hash(parent_node_id, 59, limit, $page_limit,
attribute_filter,  
array(and,array('stone_product/carat','in',$carat_in), 
array('stone_product/clarity','in',$clarity_in))))

let fcarat_in='%'|concat($carat,'%')  
let fclarity_in='%'|concat($clarity,'%')

let exactmatches=count($exactresults)
let fuzzyresults=fetch(content,tree,hash(parent_node_id, 59, limit, sub($page_limit,$exactmatches),
attribute_filter,  
array(and,array('stone_product/fcarat','like',$fcarat_in), 
array('stone_product/fclarity','like',$fclarity_in))))
}

<form action="{"/gia_certificated_diamonds"|ezurl}" method="get">
<div class="maincontentheader">
<h1>Stone Search</h1>
</div>

<div class="block">
<label>{"Carat"|i18n("design/standard/content/search")}</label><div class="labelbreak"></div>
<input class="box" type="text" size="40" name="search_carat" value="{$carat|wash}" />
</div>

<div class="block">
<label>{"Clarity"|i18n("design/standard/content/search")}</label><div class="labelbreak"></div>
<input class="box" type="text" size="40" name="search_clarity" value="{$clarity|wash}" />
</div>

<div class="break"></div>
</div>

<div class="buttonblock'">
<input class="button" type="submit" name="SearchButton" value="{'Search'|i18n('design/standard/content/search')}" />
</div>

<h2>Display the Results</h2>
<br>

exact results:
{section var=exactresults loop=$exactresults sequence=array(bglight,bgdark)}

   {node_view_gui view=line content_node=$exactresults.item}<br>
  
{/section}
<br>
fuzzy results:
{section var=fuzzyresults loop=$fuzzyresults sequence=array(bglight,bgdark)}

   {node_view_gui view=line content_node=$fuzzyresults.item}<br>
  
{/section}

</form>


{/let}
{/let}
{/let}

I've now got to add more fields and change them to dropdown lists, but the guts is well and truly there.

Many thanks for your help.

Regards Steve.

http://www.oneworldmarket.co.uk

Paul Borgermans

Friday 03 September 2004 9:54:17 am

you're welcome :-)

good luck on your further journey with ez publish!

-paul

eZ Publish, eZ Find, Solr expert consulting and training
http://twitter.com/paulborgermans

steve walker

Tuesday 07 September 2004 1:26:50 am

Hi there,

Have realised there is one issue stopping this working as it should - I think (hope) its only a minor tweak.

The problem is that the fuzzy values should always have the non-fuzzy values in their array as well. To try to explain, if I have:

colour = G
fuzzy colours = F H

size = 4
fuzzy size = 3 5

The fuzzy fetch needs to be able to look for the colour 'G' as well as size '3' or '5'. In the current code the fuzzy fetch only looks at stones that have values totally different (but one step away) - to cure this the fuzzy values would need to have the exact ones in there, so the example would change to:

colour = G
fuzzy colours = F G H

size = 4
fuzzy size = 3 4 5

The problem now is duplicates found in the two fetches.

Is it possible to take two fetches and make a comparison such that the second fetch removes any duplicates which it finds through checking the first fetch?

Many thanks, Steve.

http://www.oneworldmarket.co.uk

eZ debug

Timing: Jan 19 2025 11:51:15
Script start
Timing: Jan 19 2025 11:51:15
Module start 'content'
Timing: Jan 19 2025 11:51:16
Module end 'content'
Timing: Jan 19 2025 11:51:17
Script end

Main resources:

Total runtime1.4096 sec
Peak memory usage4,096.0000 KB
Database Queries194

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0065 589.6250180.8125
Module start 'content' 0.00651.2824 770.4375540.2422
Module end 'content' 1.28890.1207 1,310.6797356.6953
Script end 1.4095  1,667.3750 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00410.2938210.0002
Check MTime0.00160.1104210.0001
Mysql Total
Database connection0.00100.069210.0010
Mysqli_queries1.342495.23231940.0069
Looping result0.00180.12861920.0000
Template Total1.378297.820.6891
Template load0.00220.153720.0011
Template processing1.376097.619220.6880
Template load and register function0.00020.016710.0002
states
state_id_array0.00110.075310.0011
state_identifier_array0.00150.103020.0007
Override
Cache load0.00180.1273300.0001
Sytem overhead
Fetch class attribute can translate value0.00110.081130.0004
Fetch class attribute name0.00050.035640.0001
XML
Image XML parsing0.00090.061930.0003
class_abstraction
Instantiating content class attribute0.00000.000540.0000
General
dbfile0.00200.1391280.0001
String conversion0.00000.000530.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
3content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
8content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
1content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
4content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 19
 Number of unique templates used: 7

Time used to render debug report: 0.0001 secs