没有通配符星号的弹性搜索查询

时间:2018-09-13 20:36:33

标签: elasticsearch

我有一个与ElasticSearch有关的问题。 我有一个标题为“ MS-PS_3.2”的文档 当我仅搜索“ MS”时,它将根据查询返回文档

:query=>"*MS\\-PS_3.2*"
当我输入完整的文档标题时,它不会返回结果。查询如下所示:
:query=>"MS\\-PS_3.2"
但是,当我删除通配符时,它将返回文档
 {:query=>{:bool=>{:must=>[{:query_string=>{:query=>"*MS\\-PS_3.2*"}}, {:terms=>{:bank_id=>[4]}}]}}, :size=>10000}

我的完整查询如下:

pragma solidity ^0.4.23;
import "./ConvertLib.sol";
import "./Loans.sol";

contract Users is Loans{
   address public owner;




enum status {enable,disable}
struct User {
    string fname;
    string lname;
    string email;
    uint phone;
    string fileHash;
    status ustatus;
    bool check;
    address add;
}

mapping (address => User) users;
address[] public allUsers;


function setUser(string _fname,string _lname,string _email,uint _phone,string _fileHash) public payable returns(bool) {


    User storage newUser = users[msg.sender];
    newUser.fname = _fname;
    newUser.lname = _lname;
    newUser.email = _email;
    newUser.phone = _phone;
    newUser.check = true;
    newUser.fileHash = _fileHash;
    newUser.add = msg.sender;
    allUsers.push(msg.sender) -1;

   // Both ways it is nor working

   // Loans.requestLoan(250,"EUR","ASD",123,"asd");
    Loans.Loan storage newLoan = loans[msg.sender];
    newLoan.amount = 250;
    newLoan.currency = "Euro";
    newLoan.loanDescription = "Description";
    newLoan.endDate = 23;
    newLoan.returnPolicy = "ad";
    allLoans.push(msg.sender) -1;
    return true;

}

查询中是否需要更改?

1 个答案:

答案 0 :(得分:1)

在将查询用作请求参数的一部分时,请尝试使用:query=>\*MS\\-PS_3.28\*。 当我使用请求正文搜索时,它似乎对我有用,但是您想尝试使用"query" : "\\*MS\\-PS_3.2\\*"吗?