solrJ(bean)
package solr;
import org.apache.solr.client.solrj.beans.Field;
/**
* managed-schema文件定義的自段:其中foodName使用ik分詞
<field name="foodId" type="int" indexed="false" stored="true"/>
<field name="foodName" type="text_ik" indexed="true" stored="true"/>
<field name="price" type="int" indexed="false" stored="true"/>
<field name="typeName" type="string" indexed="true" stored="true"/>
測試數據:
id foodName price foodType
1 青椒炒蛋 10 湘菜
2 蝦仁炒蛋 25 粵菜
* 通過創建bean的方式添加到索引庫
*
* @author Administrator
*
*/
public class Foods {
@Field
private String id;
@Field
private int foodId;
@Field
private String foodName;
@Field
private int price;
@Field
private String typeName;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public int getFoodId() {
return foodId;
}
public void setFoodId(int foodId) {
this.foodId = foodId;
}
public String getFoodName() {
return foodName;
}
public void setFoodName(String foodName) {
this.foodName = foodName;
}
public int getPrice() {
return price;
}
public void setPrice(int price) {
this.price = price;
}
public String getTypeName() {
return typeName;
}
public void setTypeName(String typeName) {
this.typeName = typeName;
}
}
import org.apache.solr.client.solrj.beans.Field;
/**
* managed-schema文件定義的自段:其中foodName使用ik分詞
<field name="foodId" type="int" indexed="false" stored="true"/>
<field name="foodName" type="text_ik" indexed="true" stored="true"/>
<field name="price" type="int" indexed="false" stored="true"/>
<field name="typeName" type="string" indexed="true" stored="true"/>
測試數據:
id foodName price foodType
1 青椒炒蛋 10 湘菜
2 蝦仁炒蛋 25 粵菜
* 通過創建bean的方式添加到索引庫
*
* @author Administrator
*
*/
public class Foods {
@Field
private String id;
@Field
private int foodId;
@Field
private String foodName;
@Field
private int price;
@Field
private String typeName;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public int getFoodId() {
return foodId;
}
public void setFoodId(int foodId) {
this.foodId = foodId;
}
public String getFoodName() {
return foodName;
}
public void setFoodName(String foodName) {
this.foodName = foodName;
}
public int getPrice() {
return price;
}
public void setPrice(int price) {
this.price = price;
}
public String getTypeName() {
return typeName;
}
public void setTypeName(String typeName) {
this.typeName = typeName;
}
}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.