안녕 내 몽고 DB를 필드를 다음과 같이 아래mongodb 배열 필드에서 전체 텍스트 검색을 수행하는 방법은 무엇입니까?
"_id" : ObjectId("51d582be7a8d51bd29ca78a3"),
"Filename" : "sample.pdfe",
"Title" : null,
"Author" : null,
"ContentType" : "application/x-msdownload; format=pe32",
"url" : "Z:sample.pdf",
"Keywords" : ["php","java",".net","python"]
내가 두 필드에 텍스트 인덱스를 만들 명령 아래에 사용한 인덱스 필드
m = new Mongo("10.0.0.26", 27017);
DB db = m.getDB("soft") ;
DBCollection col = db.getCollection("metadatanew") ;
String collection = col.toString();
DBObject searchCmd = new BasicDBObject();
searchCmd.put("text", collection);
searchCmd.put("search", name);
CommandResult commandResult = db.command(searchCmd);
BasicDBList results = (BasicDBList)commandResult.get("results");
for (Iterator <Object> it = results.iterator();it.hasNext();)
{
BasicDBObject result = (BasicDBObject) it.next();
BasicDBObject dbo = (BasicDBObject) result.get("obj");
System.out.println(dbo.getString("Filename"));
}
에서 전체 텍스트 검색을 할 내 코드입니다 :
db.metadatanew.ensureIndex({'Filename':"text"}, {'Keywords':"text"})
나는 단지 파일 이름에 전체 텍스트 검색을 할 수 있습니다 파일 이름과 키워드 텍스트 인덱스를 만들어 왔지만, PLE, 내 코드가 어떤 잘못 ase help me
감사의 작업을 – user2545106