# 解决coreseek生成索引时报错WARNING: attribute 'id' not found - IGNORING

**URL:** <https://www.shiqidu.com/t/topic/193>\
**Category:** 开发调优\
**Tags:** Sphinx\
**Created:** [July 18, 2017, 1:22pm UTC](https://www.shiqidu.com/t/topic/193 "2017-07-18T13:22:08Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Leon](https://www.shiqidu.com/user_avatar/www.shiqidu.com/leon/32/5_2.png) [@Leon](https://www.shiqidu.com/u/Leon)\
**Post date:** [July 18, 2017, 1:22pm UTC](https://www.shiqidu.com/t/topic/193/1 "2017-07-18T13:22:08Z")

</div>

今天在配置完`sphinx`新索引后，生成索引时报错

```bash
indexing index 'eaxing'...
WARNING: attribute 'id' not found - IGNORING
collected 22 docs, 0.0 MB
sorted 0.0 Mhits, 100.0% done
total 22 docs, 27644 bytes
total 0.011 sec, 2414112 bytes/sec, 1921.22 docs/sec

```

原因是`sphinx`不能使用主键来做属性字段，而我的源配置里是这么写的

```bash
sql_query = SELECT id, discussion_id,content FROM sq_posts
sql_attr_uint = id
sql_attr_uint = discussion_id

```

`id`是我`posts`表的主键，所以需要给个别名，like this

```bash
sql_query = SELECT id,id as aid, discussion_id,content FROM sq_posts
sql_attr_uint = aid
sql_attr_uint = discussion_id

```

然后再试试生成索引

```bash
./indexer -c /usr/local/coreseek/etc/csft.conf --all --rotate

```

```bash
indexing index 'eaxing'...
collected 22 docs, 0.0 MB
sorted 0.0 Mhits, 100.0% done
total 22 docs, 27644 bytes
total 0.010 sec, 2573210 bytes/sec, 2047.84 docs/sec

```

ok了，这下就没错了。

---

<div class="post-metadata">

**Author:** ![zousaisai](https://www.shiqidu.com/user_avatar/www.shiqidu.com/zousaisai/32/470_2.png) [@zousaisai](https://www.shiqidu.com/u/zousaisai)\
**Post date:** [July 27, 2017, 1:54pm UTC](https://www.shiqidu.com/t/topic/193/2 "2017-07-27T13:54:02Z")

</div>

555555

---

<div class="post-metadata">

**Author:** ![caojie](https://www.shiqidu.com/user_avatar/www.shiqidu.com/caojie/32/465_2.png) [@caojie](https://www.shiqidu.com/u/caojie)\
**Post date:** [July 30, 2017, 8:34am UTC](https://www.shiqidu.com/t/topic/193/3 "2017-07-30T08:34:24Z")

</div>

666

---

<div class="post-metadata">

**Author:** ![Leon](https://www.shiqidu.com/user_avatar/www.shiqidu.com/leon/32/5_2.png) [@Leon](https://www.shiqidu.com/u/Leon)\
**Post date:** [July 30, 2017, 8:44am UTC](https://www.shiqidu.com/t/topic/193/4 "2017-07-30T08:44:01Z")

</div>

@草芥: 777
