New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CFSearch can't order results?? #69

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

Comments

Projects
None yet
3 participants
@acg10

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

This comment has been minimized.

mgrandb commented May 22, 2018

I think you can use Querysort().

@MFernstrom

This comment has been minimized.

Member

MFernstrom commented May 23, 2018

@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

This comment has been minimized.

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 possible say to Lucene that search in the index sorted?? Thax everybody

@acg10

This comment has been minimized.

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

This comment has been minimized.

Member

MFernstrom commented May 29, 2018

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

@acg10

This comment has been minimized.

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 Jun 6, 2018

@acg10 acg10 reopened this Jun 6, 2018

@MFernstrom

This comment has been minimized.

Member

MFernstrom commented Jun 6, 2018

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 join this conversation on GitHub. Already have an account? Sign in to comment