Question

I'm using solr4.7 with CoreContainer to create core and EmbeddedSolrServer to connect and ModifiableSolrParams to fetch the data..

I have configured "solrconfig.xml" with requestHelper "import" to import the data and other configuration file for data config as under....

    <dataConfig>
        <dataSource driver="com.mysql.jdbc.Driver"
            url="jdbc:mysql://localhost:3306/koupon"
            user="root"
            password="root" />
        <document>
            <entity name="koupon" 
                query="SELECT k.kouponid as kid, k.name, k.image,k.description,k.discount as discount,
    k.startdate,k.enddate,k.actualamount,
    k.discountamount,k.discountamount, c.name as category
    FROM koupon.koupon k
    INNER JOIN koupon.category c on c.categoryid = k.categoryid
    where 

k.startDate <= NOW() and endDate >= NOW()

AND c.isActive=true AND c.isDeleted=false AND k.isActive =true AND lower(k.status)=lower('approved')
    order by k.kouponid">

                <field column="kid" name="kid"/>
                <field column="name" name="name"/>
                <field column="image" name="image"/>
                <field column="description" name="description"/>
                <field column="startdate" name="startdate"/>
                <field column="enddate" name="enddate"/>
                <field column="actualamount" name="actualamount"/>
                <field column="discountamount" name="discountamount"/>
                <field column="discount" name="discount"/>
                <field column="category" name="category"/>
            </entity>
        </document>
    </dataConfig>

In this code use "k.startDate <= NOW() and endDate >= NOW()" for fetching in between record but solr query not providing this.

I have one solution that's start "To" End but that's not exact solution..

I am very tired for this Issue any know about this? How to solve this ?

Était-ce utile?

La solution

You can try to use this mysql query for indexing:

WHERE (NOW() BETWEEN k.startDate and k.endDate)

instead of:

k.startDate <= NOW() and endDate >= NOW()

to prevent the error

The value of attribute "query" associated with an element type "entity" must not contain the '<' character

For your Solr query

startdate:[* to NOW]

to work, make sure your startdate field conforms to the Solr dateField type. For more info on this, check this link

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top