8000 CFSearch can't order results?? · Issue #69 · OpenBD/openbd-core · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
This repository was archived by the owner on May 7, 2024. It is now read-only.

CFSearch can't order results?? #69

Open
acg10 opened this issue May 22, 2018 · 7 comments
Open

CFSearch can't order results?? #69

acg10 opened this issue May 22, 2018 · 7 comments

Comments

@acg10
Copy link
acg10 commented May 22, 2018

Hi everybody.
I'm a project that use Razuna, an DAM platform what use OpenBD. My problem is that this App use Lucene like search-engine and i can't sort the results.
I see so in Adobe ColdFusion 10 is possible order the results with a new param called "orderBy", but this not work in OpenBD.
Is posible use the CFSearch class to sort my results???
Thanx everybody

@mgrandb
Copy link
mgrandb commented May 22, 2018

I think you can use Querysort().

@MFernstrom
Copy link
Member

@acg10, cfsearch returns a query object, so you can use querySort().

Example

<cfset collectionCreate( collection="mycollection", storebody=false )>
<cfset collectionIndexPath( collection="mycollection", key="/Library/Java/JavaVirtualMachines/jdk1.8.0_152.jdk/Contents", recurse=true )>
<cfsearch collection="mycollection" criteria="*" name="theSearch">
<cfdump var="#theSearch#">
<cfset querySort( theSearch, "size", "numeric" )> 
<cfdump var="#theSearch#">

@acg10
Copy link
Author
acg10 commented May 24, 2018

Thax for the replies. My problem is that im use pagination in the search (maxrows param), so my returned query object not contains all the data. Is 8000 possible say to Lucene that search in the index sorted?? Thax everybody

@acg10
Copy link
Author
acg10 commented May 29, 2018

com/bluedreagon/search/...
QueryRun -> Modify searcher with Sort class of Lucene and ignore the scores results.
DocumentWrap -> Add to document SortedDocVAluesField class.
https://lucene.apache.org/core/5_5_1/core/index.html
thank you can close issue.

@MFernstrom
Copy link
Member

Can you show an example of how you did that? I'm curious :)

@acg10
Copy link
Author
acg10 commented Jun 6, 2018

Hi MFernstrom:
In Queryrun.java, before that IndexSearch call search method, can pass a Sort class to say Lucene search in the documents sorted by an field. I'm the "filename" field so before write:

String field = "title";
SortField.Type type = SortField.Type.STRING;
boolean descending = true;
SortField sortField = new SortField(field, type, descending);
Sort sorter = new Sort(sortField);

TopDocs localTopDocs = localIndexSearcher.search(this.queryAttributes.getQuery(), localCollection.getTotalDocs(), sorter);

And Lucene return the TopDocs sorted by this field "filename". A good idea is parametrizer this field in cfsearch function to can get the results sorted in Lucene.

Thx for everthing and sorry my bad english

@acg10 acg10 closed this as completed Jun 6, 2018
@acg10 acg10 reopened this Jun 6, 2018
@MFernstrom
Copy link
Member

Nice @acg10 , thanks for sharing!
And don't worry about your English, it's not my native language either, you're fine :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants
0