Configuring the search function in the Play CRUD module

Editing: the search works in a very simple way, the search for any text is entered into all fields of the String element of the corresponding model without special search operators.

If there is a way to tweak the search, I would like to know. Right now, it looks like I just need to ignore the built-in search materials and collapse my own.


With the addition of the field, noteshe began to return nothing, not all. The only thing that has worked so far is to enter a “test” in the search field, which returns a record with the “test” in the comments field. The search for "notes: test" or "notes = test" does not work, nor does it try to find the agentor fields status. I tried things like "1400", the value of which I checked, is present in the agent field via phpMyAdmin, and things like "0" or "VALID" for the status field, which is all the entries.

model fields:

public class AgentShift extends Model {
    public enum Status { VALID, RESCHEDULED, EXTENDED, DELETED } // REDUCED?

    @Required @Min(1000) @Max(99999)
    public int agent;
    public Status status = Status.VALID;

    @Required
    @Columns(columns={@Column(name="start_time"),@Column(name="end_time")})
    @Type(type="org.joda.time.contrib.hibernate.PersistentInterval")
    public Interval scheduled;

    @Type(type="org.joda.time.contrib.hibernate.PersistentLocalTimeAsTime")
    public LocalTime agent_in;
    @Type(type="org.joda.time.contrib.hibernate.PersistentLocalTimeAsTime")
    public LocalTime agent_out;

    public String notes;
}

modified crud list page:

#{extends 'main.html' /}
#{set title: 'Agent Shifts' /} 

<div id="crudList" class="${type.name}">

    <h2 id="crudListTitle">&{'crud.list.title', type.name}</h2>

    <div id="crudListSearch">
        #{crud.search /}
    </div>

    <div id="crudListTable">
        #{crud.table fields:['id','agent','scheduled','status','notes'] }
            #{crud.custom 'scheduled'}
                #{if object.scheduled.getStart().toDateMidnight().equals(object.scheduled.getEnd().toDateMidnight())}
                    ${org.joda.time.format.DateTimeFormat.forStyle("SS").printTo(out, object.scheduled.getStart())} to 
                    ${org.joda.time.format.DateTimeFormat.forStyle("-S").printTo(out, object.scheduled.getEnd())}
                #{/if}
                #{else}
                    ${org.joda.time.format.DateTimeFormat.forStyle("SS").printTo(out, object.scheduled.getStart())} to 
                    ${org.joda.time.format.DateTimeFormat.forStyle("SS").printTo(out, object.scheduled.getEnd())}
                #{/else}
            #{/crud.custom}
            *{
            #{crud.custom 'entered_by'}
                #{if object.entered_by}
                    ${object.entered_by}
                #{/if}
                #{else} ?
                #{/else}
            #{/crud.custom}
            #{crud.custom 'created'}
                ${org.joda.time.format.DateTimeFormat.forStyle("SS").printTo(out, object.created)}
            #{/crud.custom}
                }*
        #{/crud.table}
    </div>

    <div id="crudListPagination">
        #{crud.pagination /}
    </div>

    <p id="crudListAdd">
        <a href="@{blank()}">&{'crud.add', type.modelName}</a>
    </p>

</div>
+3
source share
2 answers

, CRUD, , .

:

 <field name>:<value>

:

name:Liam

, Liam. , . , @Lob, , , .

, Play 1.1 , ( ), . , 1.2.1 ( , , , )

:

.

: , ? , Hibernate, , , , . , Play .

, , CRUD, .

rel Interval LocalTime . , ... , :

+2

.

1) :

@ElasticSearchController.For(ElasticSearchSampleModel.class)
public class ElasticSearchExample extends ElasticSearchController {

}

2) JPA @ElasticSearchable:

@Entity
@ElasticSearchable
public class ElasticSearchSampleModel extends Model {

    /** The Constant serialVersionUID. */
    private static final long serialVersionUID = 1L;

    /** The field1. */
    public String field1;

    /** The field2. */
    public String field2;

    /**
     * To String
     * 
     * @see play.db.jpa.JPABase#toString()
     */
    @Override
    public String toString() {
        return "ElasticSearchSampleModel [field1=" + this.field1 + ", field2=" + this.field2 + "]";
    }

}

http://geeks.aretotally.in/play-framework-module-elastic-search-distributed-searching-with-json-http-rest-or-java.

+2

All Articles