Help with search

View: New views
3 Messages — Rating Filter:   Alert me  

Help with search

by masjab :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello, 
I need some help because I do absolutely not know how do solve my problem:

I have a searchPage that calls a search.xq which should dynamically search for different entries.
It looks like this:(orbeon..)

The XML-output that is done looks like this:

But I don“t know how to concat/combine everything into one search.xq. Right now my search.xq looks like this:

xquery version "1.0";
declare namespace exist = "http://exist.sourceforge.net/NS/exist";
declare namespace xmldb = "http://exist-db.org/xquery/xmldb";
declare namespace request="http://exist-db.org/xquery/request";
(:declare option exist:serialize "method=html media-type=text/html indent=yes"; :)
let $sD := request:get-data()
let $coll1 := xmldb:xcollection('/db/dictionary/data')//root/entry
return 

<result>
for $row in $sD/search/select
let $name := string($row/name)
let $value := string($row/value)
let $interpretAs := string($row/interpretAs)
let $operator := string($row/operator) 

for $search at $count in
 for $result in $coll1 
  where $result[child::*[./fn:name() = $name] = $value]  
  return $result
return 
    $search
}
</result>


And there is the problem that an user can add lots of new search- constraint..

THX

















-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
Studies have shown that voting for your favorite open source project,
along with a healthy diet, reduces your potential for chronic lameness
and boredom. Vote Now at http://www.sourceforge.net/community/cca08
_______________________________________________
Exist-open mailing list
Exist-open@...
https://lists.sourceforge.net/lists/listinfo/exist-open

Re: Help with search

by Wolfgang Meier-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

> I have a searchPage that calls a search.xq which should dynamically search
> for different entries.

For more complex dynamic queries, it is often easier to construct the
query as a string in your XQuery, then pass it to util:eval() for
execution, e.g.

let $query := local:build-query($term1, $value1),
    $hits := util:eval($query)
return ...

Some of the examples that ship with eXist use this approach.

Wolfgang

-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
Studies have shown that voting for your favorite open source project,
along with a healthy diet, reduces your potential for chronic lameness
and boredom. Vote Now at http://www.sourceforge.net/community/cca08
_______________________________________________
Exist-open mailing list
Exist-open@...
https://lists.sourceforge.net/lists/listinfo/exist-open

Parent Message unknown Re: Help with search

by Wolfgang Meier-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

> The xquery should concat/combine these selects using the operator(AND //
> OR).

Just have a look at the available XQuery functions, for example:

http://en.wikibooks.org/wiki/XQuery/Displaying_Lists

> My xquery below does work as an union of all selects =(
> let $sD := request:get-data()
> let $coll1 := xmldb:xcollection('/db/dictionary/data')//root/entry
> return
> <result>
> {
> for $row in $sD/search/select
> let $name := string($row/name)
> let $value := string($row/value)
> let $operator := string($row/operator)
> for $search at $count in
>  for $result in $coll1
>   where $result[child::*[./fn:name() = $name] = $value]
>   return $result
> return
>     $search
> }
> </result>

>From a performance point of view, this query is really terrible. I
would really suggest to create a single query string instead and pass
that to util:eval.

Wolfgang

-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
Studies have shown that voting for your favorite open source project,
along with a healthy diet, reduces your potential for chronic lameness
and boredom. Vote Now at http://www.sourceforge.net/community/cca08
_______________________________________________
Exist-open mailing list
Exist-open@...
https://lists.sourceforge.net/lists/listinfo/exist-open
LightInTheBox - Buy quality products at wholesale price