Подтвердить что ты не робот

Не удалось выполнить правильный мониторинг пути или запрос с помощью Firebase и ElasticSearch (с помощью фонарика)

Я пытаюсь интегрировать ElasticSearch с Firebase. Я использую интеграцию фонарей от Firebase, чтобы установить ut all up. Я развернул код в Heroku, как описано в репозитории Github, указанном выше.

Он работает в том смысле, что когда я вставляю запрос в объект /search/request/, я получаю результат /search/response. Но результаты немного грязные, а не правильные. Но я не могу понять, что не так.

Это то, что определено в config.js, где я определяю пути для мониторинга:

/** Paths to Monitor
 *
 * Each path can have these keys:
 * {string}   path:    [required] the Firebase path to be monitored, for example, `users/profiles`
 *                     would monitor https://<instance>.firebaseio.com/users/profiles
 * {string}   index:   [required] the name of the ES index to write data into
 * {string}   type:    [required] name of the ES object type this document will be stored as
 * {Array}    fields:  list of fields to be monitored and indexed (defaults to all fields, ignored if "parser" is specified)
 * {Array}    omit:    list of fields that should not be indexed in ES (ignored if "parser" is specified)
 * {Function} filter:  if provided, only records that return true are indexed
 * {Function} parser:  if provided, the results of this function are passed to ES, rather than the raw data (fields is ignored if this is used)
 *
 * To store your paths dynamically, rather than specifying them all here, you can store them in Firebase.
 * Format each path object with the same keys described above, and store the array of paths at whatever
 * location you specified in the FB_PATHS variable. Be sure to restrict that data in your Security Rules.
 ****************************************************/

exports.paths = [{
    path: "users",
    index: "firebase",
    type: "user"
}, {
    path: "messages",
    index: "firebase",
    type: "message",
    fields: ['msg', 'name'],
    filter: function(data) {
        return data.name !== 'system';
    }
}];

Это структура пользователя node в Firebase (он находится в корне).

"users" : {
    "userid123" : {
      "friends" : {
        "userid42" : 1
      },
      "recs" : {
        "-recid1234" : 0
      },
      "user_info" : {
        "createdAt" : 1475157596,
        "email" : "[email protected]",
        "name" : "Firstname Lastname Johnson",
        "profilePicture" : "png.jpg",
        "pushId" : {
        },
        "username" : "userLooser"
      }
    },
    "userid42" : {
      "friends" : {
        "userid123" : 1,
        "test1" : 1
      },
      "recs" : {
        "-recid5678" : 0
      },
      "user_info" : {
        "email" : "[email protected]",
        "name" : "Firstname Lastname",
        "phoneNumber" : "",
        "profilePicture" : "jpg.png",
        "pushId" : {

        },
        "username" : "userName"
      }
    }
  }
}

То, что я хочу достичь, - это поиск имени пользователя и возврат результатов. Все, что мне действительно нужно, это имя пользователя и пользователя.

Изображение поискового запроса firebase

Но я получаю ответ ниже, когда я запрашиваю объект на изображении выше:

  "search" : {
    "response" : {
      "index" : {
        ".priority" : 1.477326417519E12,
        "hits" : [ {
          "_id" : "test1",
          "_index" : "firebase",
          "_score" : 1,
          "_source" : {
            "friends" : {
              "test1" : 1
            },
            "recs" : {
            },
            "user_info" : {
              "createdAt" : 1475157596,
              "name" : "Testbruker 1",
              "username" : "testuzer"
            }
          },
          "_type" : "user"
        }, {
          "_id" : "userid123",
          "_index" : "firebase",
          "_score" : 1,
          "_source" : {
            "friends" : {
            },
            "recs" : {

            },
            "user_info" : {
              "email" : "",
              "name" : "Firstname Lastname",
              "phoneNumber" : "",
              "profilePicture" : "",
              "pushId" : {
              },
              "username" : "profileName"
            }
          },
          "_type" : "user"
        }, {
          "_id" : "userid42",
          "_index" : "firebase",
          "_score" : 1,
          "_source" : {
            "friends" : {
            },
            "recs" : {

            },
            "user_info" : {
              "createdAt" : 1475157596,
              "email" : "[email protected]",
              "name" : "Firstname Lastname Johnson",
              "profilePicture" : "",
              "pushId" : {
              },
              "username" : "userLooser"
            }
          },
          "_type" : "user"
        } ],
        "max_score" : 1,
        "total" : 3
      },
      "query" : {
        ".priority" : 1.477326417484E12,
        "hits" : [ {
          "_id" : "test1",
          "_index" : "firebase",
          "_score" : 1,
          "_source" : {
            "friends" : {
              "test1" : 1
            },
            "recs" : {
            },
            "user_info" : {
              "createdAt" : 1475157596,
              "name" : "Testbruker 1",
              "username" : "testuzer"
            }
          },
          "_type" : "user"
        }, {
          "_id" : "userid42",
          "_index" : "firebase",
          "_score" : 1,
          "_source" : {
            "friends" : {

            },
            "recs" : {

            },
            "user_info" : {
              "email" : "",
              "name" : "Firstname Lastname",
              "phoneNumber" : "",
              "profilePicture" : "",
              "pushId" : {

              },
              "username" : "profileName"
            }
          },
          "_type" : "user"
        }, {
          "_id" : "userid123",
          "_index" : "firebase",
          "_score" : 1,
          "_source" : {
            "friends" : {
            },
            "recs" : {

            },
            "user_info" : {
              "createdAt" : 1475157596,
              "email" : "[email protected]",
              "name" : "Firstname Lastname Johnson",
              "profilePicture" : "",
              "pushId" : {

              },
              "username" : "userLooser"
            }
          },
          "_type" : "user"
        } ],
        "max_score" : 1,
        "total" : 3
      },
      "type" : {
        ".priority" : 1.477326417503E12,
        "hits" : [ {
          "_id" : "test1",
          "_index" : "firebase",
          "_score" : 1,
          "_source" : {
            "friends" : {
              "test1" : 1
            },
            "recs" : {
            },
            "user_info" : {
              "createdAt" : 1475157596,
              "name" : "Testbruker 1",
              "username" : "testuzer"
            }
          },
          "_type" : "user"
        }, {
          "_id" : "userid42",
          // Same content as above
        }, {
          "_id" : "userid123",
          // Same content as above
        } ],
        "max_score" : 1,
        "total" : 3
      }
    }
  }

Что:

  • A) Не возвращает правильную сортировку. Первый результат совсем не соответствовал моему поисковому запросу, он просто выглядит как он возвращает всех пользователей в случайном порядке.
  • B) Ответ действительно грязный. в разделе /response есть три узла query, type и index, содержащие много ударов.

Итак, кто-нибудь знает, что случилось? Как я могу создать запрос или создать монитор пути, чтобы поиск работал? И, может быть, получить более простой ответ?

4b9b3361

Ответ 1

Фонарик действительно ищет запросы в файле search/requests/$, который должен содержать документ с типом полей, индексом, запросом. Он дает ответ на результат поиска/ответа/$с результатами. Если вы хотите протестировать, добавив вручную ключи, попробуйте поместить запрос под другой node например. Поиск/запросы/testkey123.

Ответ 2

Я все время пытался и после нескольких часов пытался:

В моем файле .config проекта Фонарик я установил:

exports.paths = [
  {
    path : "albuns",
    index: "firebase",
    type : "album",
    fields: ['nome']
  }
];

Теперь вам нужно отправить вызов http PUT для Firebase <URL_PROJECT>/search/request/<ID_CREATED_FOR_YOU>.json (используйте application/json), вы можете протестировать его с помощью Расширение почтмана, тело оставалось:

{
  "index": "firebase",
  "type": "album",
  "q": "John*"
}